a weird Javascript error

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

a weird Javascript error

 
0
  #1
Nov 15th, 2004
A piece of JavaScript on one of our pages gives an access denied error.
In itself nothing strange, it's a reasonably well defined error after all

What is strange is that the error ONLY happens on that page (despite identical calls to the JavaScript function appearing on several other pages) and that the error ONLY appears if the page is loaded in a fresh browser instance. If I reload the page before executing the script (which is triggered in the onblur event of a formfield) the error does not appear and the script is executed successfully.

The function of this script is to download some data from the application server and pipe that data into an HTML element (in this case a td, in other pages it may be a div).

Can anyone shed some light as to where to look for the cause of this?

Here's the relevant JavaScript and HTML (fragments of course):
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var myFrames = new Array();
  2. function frameObj(index) {
  3. this.busy = true;
  4. this.index = index;
  5. obj = document.createElement("iframe");
  6. obj.style.height = "0px";
  7. obj.style.width = "0px";
  8. this.frame = document.body.appendChild(obj);
  9. if (this.frame.contentWindow)
  10. this.frameDoc = obj.contentWindow.document;
  11. else if (this.frame.contentDocument)
  12. this.frameDoc = obj.contentDocument;
  13. else
  14. this.frameDoc = null;
  15. }
  16. function findFrame() {
  17. for (i = 0; i < myFrames.length; i++) {
  18. if (!myFrames[i].busy) {
  19. myFrames[i].busy = true;
  20. break;
  21. }
  22. }
  23. if (i >= myFrames.length)
  24. myFrames[i] = new frameObj(i);
  25. return myFrames[i];
  26. }
  27. function getHTML2(oElement, form, data) {
  28. dataElement = oElement;
  29. if (!(frame = findFrame()))
  30. return;
  31. if (frame.frameDoc) {
  32. elms = form.elements;
  33. doc = frame.frameDoc;
  34. doc.open();
  35. doc.write("<html><body><form name=\"send\" method=\"post\" action=\"" +
  36. form.action + "\">");
  37. doc.write("<input type=\"hidden\" name=\"iframe\" value=\"" + frame.index + "\">");
  38. doc.write("<input type=\"hidden\" name=\"data\" value=\"" + data + "\">");
  39. for (i = 0; i < elms.length; i++) {
  40. elm = elms[i];
  41. switch (elm.type) {
  42. case 'button':
  43. case 'file':
  44. case 'reset':
  45. case 'submit':
  46. continue;
  47. case 'checkbox':
  48. if (elm.checked == false)
  49. continue;
  50. case 'radio':
  51. if (elm.value == '')
  52. continue;
  53. }
  54. doc.write("<input type=\"hidden\" name=\"" + elm.name +
  55. "\" value=\"" + elm.value + "\">");
  56. }
  57. doc.write("</form></body></html>");
  58. doc.close();
  59. doc.forms["send"].submit();
  60. }
  61. }
  62. function getHTMLDone2(ind, result) {
  63. dataElement.innerHTML = result;
  64. dataElement.setAttribute('hasContent',true);
  65. elementInitTabctls(dataElement);
  66. elementTablesInit(dataElement);
  67. myFrames[ind].busy = false;
  68. }

Code is part of a JSP, JSP code resolves correctly.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script language="JavaScript">
  2. function getOnEnter() {
  3. if (window.event.keyCode == 13 ) {
  4. window.event.returnValue = false;
  5. getHTML2(ss, pageform, 'ss');
  6. }
  7. }
  8. function aktieOnEnter(arg) {
  9. if (window.event.keyCode == 13) {
  10. window.event.returnValue = false;
  11. faktie(arg);
  12. }
  13. }
  14. function faktie(arg) {
  15. document.pageform.uaktie.value = arg;
  16. document.pageform.submit();
  17. }
  18. </script>
  19. <form name="pageform" action="../servlet/<%= ks.getServletName() %>" method="post">
  20. <input type="hidden" name="pageid" value="<%= request.getAttribute("pageid") %>">
  21. <input type="hidden" name="uaktie" value="<%= uaktie.getJSPValue() %>">
  22. <div class="inh">
  23. <table class="inh" border="0" cellpadding="0" cellspacing="0">
  24. <tr>
  25. <td rowspan="3"><img src="../lib/login.gif"></td>
  26. <td class="rowhead">Naam</td>
  27. <td><input class="text" type="text" name="naam"
  28. autocomplete="off"
  29. value="<%= naam.getJSPValue() %>"
  30. onkeypress="getOnEnter();"
  31. onblur="getHTML2(ss, pageform, 'ss');"
  32. /></td>
  33.  
  34. </tr>
  35. <tr>
  36. <td class="rowhead">Wachtwoord</td>
  37. <td><input class="text" type="password" name="wachtwoord"
  38. value="<%= wachtwoord.getJSPValue() %>" /></td>
  39. </tr>
  40. <tr>
  41. <td class="rowhead" id="sh">
  42. Server
  43. </td>
  44. <td id="ss">
  45. &nbsp;
  46. </td>
  47. </tr>
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: a weird Javascript error

 
0
  #2
Nov 29th, 2004
OK, let's bump this up and provide a small update

It seems the problem happens only on Win XP with SP2 installed, on SP1 machines the code seems to works fine.

Anyone know what changes there are in the Javascript engine of IE6 between SP1 and SP2?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1
Reputation: eriasb is an unknown quantity at this point 
Solved Threads: 0
eriasb eriasb is offline Offline
Newbie Poster

Re: a weird Javascript error

 
0
  #3
Dec 28th, 2004
Hi,
I get the same problem.
Have you figured out what to do?
Please let me know if you have. I belive it has something to do with "document.write"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC