User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,862 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 8228 | Replies: 2
Reply
Join Date: Nov 2004
Location: Netherlands
Posts: 5,588
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 187
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

a weird Javascript error

  #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):
var myFrames = new Array();
function frameObj(index) {
    this.busy = true;
    this.index = index;
    obj = document.createElement("iframe");
    obj.style.height = "0px";
    obj.style.width = "0px";
    this.frame = document.body.appendChild(obj);
    if (this.frame.contentWindow)
	this.frameDoc = obj.contentWindow.document;
    else if (this.frame.contentDocument)
	this.frameDoc = obj.contentDocument;
    else
	this.frameDoc = null;
}
function findFrame() {
    for (i = 0; i < myFrames.length; i++) {
	if (!myFrames[i].busy) {
	    myFrames[i].busy = true;
	    break;
	}
    }
    if (i >= myFrames.length)
	myFrames[i] = new frameObj(i);
    return myFrames[i];
}
function getHTML2(oElement, form, data) {
	dataElement = oElement;
    if (!(frame = findFrame()))
	return;
    if (frame.frameDoc) {
	elms = form.elements;
	doc = frame.frameDoc;
	doc.open();
	doc.write("<html><body><form name=\"send\" method=\"post\" action=\"" +
	  form.action + "\">");
	doc.write("<input type=\"hidden\" name=\"iframe\" value=\"" + frame.index + "\">");
	doc.write("<input type=\"hidden\" name=\"data\" value=\"" + data + "\">");
	for (i = 0; i < elms.length; i++) {
	    elm = elms[i];
	    switch (elm.type) {
	      case 'button':
	      case 'file':
	      case 'reset':
	      case 'submit':
		continue;
	      case 'checkbox':
				if (elm.checked == false)
					continue;
	      case 'radio':
		if (elm.value == '')
		    continue;
	    }
	    doc.write("<input type=\"hidden\" name=\"" + elm.name +
	      "\" value=\"" + elm.value + "\">");
	}
	doc.write("</form></body></html>");
	doc.close();
	doc.forms["send"].submit();
    }
}
function getHTMLDone2(ind, result) {
	dataElement.innerHTML = result;
	dataElement.setAttribute('hasContent',true);
	elementInitTabctls(dataElement);
	elementTablesInit(dataElement);
    myFrames[ind].busy = false;
}

Code is part of a JSP, JSP code resolves correctly.
<script language="JavaScript">
function getOnEnter() {
	if (window.event.keyCode == 13 ) {
		window.event.returnValue = false;
		getHTML2(ss, pageform, 'ss');
	}
}
function aktieOnEnter(arg) {
	if (window.event.keyCode == 13) {
		window.event.returnValue = false;
		faktie(arg);
	}
}
function faktie(arg) {
	document.pageform.uaktie.value = arg;
	document.pageform.submit();
}
</script>
<form name="pageform" action="../servlet/<%= ks.getServletName() %>" method="post">
	<input type="hidden" name="pageid" value="<%= request.getAttribute("pageid") %>">
	<input type="hidden" name="uaktie" value="<%= uaktie.getJSPValue() %>">
<div class="inh">
	<table class="inh" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td rowspan="3"><img src="../lib/login.gif"></td>
			<td class="rowhead">Naam</td>
			<td><input class="text" type="text" name="naam" 
			  autocomplete="off"
			  value="<%= naam.getJSPValue() %>" 
			  onkeypress="getOnEnter();"
			   onblur="getHTML2(ss, pageform, 'ss');"
			/></td>

		</tr>
		<tr>
			<td class="rowhead">Wachtwoord</td>
			<td><input class="text" type="password" name="wachtwoord"
			  value="<%= wachtwoord.getJSPValue() %>" /></td>
		</tr>
		<tr>
			<td class="rowhead" id="sh">
				Server
			</td>
			<td id="ss">
			    &nbsp;
			</td>			
		</tr>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,588
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 187
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: a weird Javascript error

  #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  
Join Date: Dec 2004
Posts: 1
Reputation: eriasb is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
eriasb eriasb is offline Offline
Newbie Poster

Re: a weird Javascript error

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC