By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

Trusted Site Not So Trusted

P: 2
I have a script that uses createelement to insert new rows into a page. Those inserted rows also have onchange events that fire, validating the identity of an account. The problem is that while pre-rendered rows (ones actually embedded into the HTML) will fire the onblur event, while any rows added via the javascript function will not even pop up an alert box.

The site is added to trusted sites, and active scripting is working on that zone. The bizarre thing is that if I set the internet zone to allow active scripting, events can fire from the inserted rows without any problem. But as soon as that is turned back to disable (necessary in this company) then those inserted rows do not work anymore.

Here is the function in question:
Expand|Select|Wrap|Line Numbers
  1. function addRow(table_id, neighborhood, agent_id, ledger_type, ledger_type_label)
  2. {
  3.     var tbody = document.getElementById(table_id).getElementsByTagName("tbody")[0];
  4.     var row = document.createElement("TR");
  5.     row.id='add_row_'+document.getElementById('additionalRowCount').value;
  6.     document.getElementById('additionalRowCount').value=document.getElementById('additionalRowCount').value+1;
  7.     row.style.backgroundColor='#F6F6f6';
  8.  
  9.     var cell1 = document.createElement("TD");
  10.     var inp1 =  document.createElement("<INPUT TYPE='text' value='' size='24' maxlength='24' name='ledger_num"+ledger_type+"[]' class='textfield1' id='textaddMsgRow"+row.id+"' onChange='checkAccountNumber(this.value, \""+neighborhood+"\",\"addMsgRow"+row.id+"\",\""+agent_id+"\",\""+ledger_type_label+"\")'>");
  11.     var lineBreak = document.createElement("BR");
  12.     var accountDescSpan = document.createElement("span");
  13.     accountDescSpan.id="addMsgRow"+row.id+"_desc";
  14.     cell1.width="190";
  15.     cell1.valign="top"
  16.     cell1.appendChild(inp1);
  17.  
  18.     var lookupLink=document.createElement("a");
  19.     lookupLink.href="javascript:MM_openBrWindow('lookup/lookup_account_number.php?company="+neighborhood+"&fromID=addMsgRow"+row.id+"&ledger_type="+ledger_type_label+"','lookup','width=480,height=380');void(0)";
  20.  
  21.     var lookupImage=document.createElement("IMG");
  22.     lookupImage.src="../../../images/buttons/icon_table.gif";
  23.     lookupImage.border="0";
  24.     lookupImage.width="16";
  25.     lookupImage.height="16";
  26.  
  27.     lookupLink.appendChild(lookupImage);
  28.     cell1.appendChild(lookupLink);
  29.     cell1.appendChild(lineBreak);
  30.     cell1.appendChild(accountDescSpan);
  31.  
  32.     var cell2 = document.createElement('<TD width="20" valign="top">');
  33.     var inp2 =  document.createElement("INPUT");
  34.     inp2.type="text";
  35.     inp2.value="";
  36.     inp2.size="10";
  37.     inp2.maxlength="10";
  38.     inp2.name="ledger_amount"+ledger_type+"[]";
  39.     inp2.className="textfield1";
  40.     //cell2.width="20";
  41.     //cell2.setAttribute("valign","top");
  42.     cell2.appendChild(inp2);
  43.  
  44.     var cell3 = document.createElement('<TD width="50" valign="top">');
  45.     var inp3 =  document.createElement('<INPUT type="text" value="" size="24" maxlength="30" name="ledger_explanation'+ledger_type+'[]" class="textfield1">');
  46.     /*inp3.type="text";
  47.     inp3.value="";
  48.     inp3.size="24";
  49.     inp3.maxlength="30";
  50.     inp3.name="ledger_explanation[]";*/
  51.     inp3.className="textfield1";
  52.     //cell3.width="50";
  53.     //cell3.valign="top"
  54.     cell3.appendChild(inp3);
  55.  
  56.     var cell4 = document.createElement('<TD width="90" valign="top">');
  57.     var inp4 =  document.createElement("INPUT");
  58.     var inp4 =  document.createElement("<INPUT TYPE='text' value='' size='10' maxlength='10' name='sub_ledger"+ledger_type+"[]' class='textfield1' id='addMsgRow"+row.id+"SubLedger' onChange='checkPostingEditCode(\"messagesTable\", \"addMsgRow"+row.id+"\");checkSubledger(\"addMsgRow"+row.id+"SubLedgerMsg\", this.value, document.getElementById(\"addMsgRow"+row.id+"SubType\").options[document.getElementById(\"addMsgRow"+row.id+"SubType\").selectedIndex].value, \"addMsgRow"+row.id+"SubLedger\", \"addMsgRow"+row.id+"SubType\",\""+ledger_type_label+"\");'>");
  59.     //cell4.width="90";
  60.     //cell4.valign="top"
  61.     cell4.appendChild(inp4);
  62.  
  63.     var cell5 = document.createElement('<TD valign="top">');
  64.     var objSelect =  document.createElement("<SELECT name='sub_type"+ledger_type+"[]' id='addMsgRow"+row.id+"SubType' onChange='checkPostingEditCode(\"messagesTable\", \"addMsgRow"+row.id+"\");checkSubledger(\"addMsgRow"+row.id+"SubLedgerMsg\", document.getElementById(\"addMsgRow"+row.id+"SubLedger\").value, this.options[this.selectedIndex].value, \"addMsgRow"+row.id+"SubLedger\", \"addMsgRow"+row.id+"SubType\",\""+ledger_type_label+"\");'>");
  65.  
  66.     var objOptionDefault = document.createElement("OPTION");
  67.     objOptionDefault.text="-";
  68.     objOptionDefault.value="";
  69.     objSelect.options.add(objOptionDefault);
  70.  
  71.     var objOptionA = document.createElement("OPTION");
  72.     objOptionA.text="A";
  73.     objOptionA.value="A";
  74.     objSelect.options.add(objOptionA);
  75.  
  76.     var objOptionC = document.createElement("OPTION");
  77.     objOptionC.text="C";
  78.     objOptionC.value="C";
  79.     objSelect.options.add(objOptionC);
  80.  
  81.     var objOptionX = document.createElement("OPTION");
  82.     objOptionX.text="X";
  83.     objOptionX.value="X";
  84.     objSelect.options.add(objOptionX);
  85.  
  86.     var link=document.createElement("a");
  87.     link.href="javascript:deleteRow('"+row.id+"', '"+ledger_type_label+"');void(0)";
  88.  
  89.     objSelect.className="textfield2";
  90.     var imageObj=document.createElement("IMG");
  91.     imageObj.src="../../../images/options/minus1.gif";
  92.     imageObj.border="0";
  93.  
  94.     cell5.appendChild(objSelect);
  95.     link.appendChild(imageObj);
  96.     cell5.appendChild(link);
  97.  
  98.     var inp5 =  document.createElement("INPUT");
  99.     inp5.type="hidden";
  100.     inp5.value="";
  101.     inp5.id="addMsgRow"+row.id+"PEC";
  102.     inp5.name="pec[]";
  103.     cell5.appendChild(inp5);
  104.  
  105.     var inp6 =  document.createElement("INPUT");
  106.     inp6.type="hidden";
  107.     inp6.value="no";
  108.     inp6.id="addMsgRow"+row.id+"PECCheck";
  109.     cell5.appendChild(inp6);
  110.     cell5.width="50";
  111.  
  112.     row.appendChild(cell1);
  113.     row.appendChild(cell2);
  114.     row.appendChild(cell3);
  115.     row.appendChild(cell4);
  116.     row.appendChild(cell5);
  117.     tbody.appendChild(row);
  118. }
  119.  
Has anyone else had problems with javascript-inserted content being treated as internet zone instead of trusted zone?
Oct 18 '07 #1
Share this Question
Share on Google+
3 Replies


epots9
Expert 100+
P: 1,351
i couldn't find where you're setting the onblur attribute, what part is it and please use javascript code ([code=javascript][/code])tags
Oct 18 '07 #2

P: 2
i couldn't find where you're setting the onblur attribute, what part is it and please use javascript code ()tags
My apologies, I meant onChange. I tried testing out onBlur just now to see if I could even get an alert box to fire, which it wouldn't.

Am I not using code tags above? I thought that I was.
Oct 18 '07 #3

epots9
Expert 100+
P: 1,351
your createElement statement it wrong
Expand|Select|Wrap|Line Numbers
  1. var inp1 =  document.createElement("<INPUT TYPE='text' value='' size='24' maxlength='24' name='ledger_num"+ledger_type+"[]' class='textfield1' id='textaddMsgRow"+row.id+"' onChange='checkAccountNumber(this.value, \""+neighborhood+"\",\"addMsgRow"+row.id+"\",\""+agent_id+"\",\""+ledger_type_label+"\")'>");
  2.  
try
Expand|Select|Wrap|Line Numbers
  1. var inp1 = document.createElement("input");
  2. inp1.type = "text";
  3. inp1.size = "24";
  4. inp1.maxlength = "24";
  5. inp1.name = "ledger_num" + ledger_type + "[]";
  6. inp1.class = "textfield1";
  7. inp1.id = "textaddMsgRow" + row.id;
  8. inp1.onchange = function(){checkAccountNumber(this.value, neighborhood, "addMsgRow" + row.id, agent_id, ledger_type_label);}
  9.  
give that a test and tell us how it goes,

good luck
Oct 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.