homepage Welcome to WebmasterWorld Guest from 54.226.180.223
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
IE hangs up when writing Javascript to window
Javascript and IE interface problem
lebanks123




msg:1476631
 7:48 pm on Apr 17, 2003 (gmt 0)

I have some javascript code that is called by some HTML on our server (no problem when running locally). The following
is the scenario and code. I would appreciate any help I can get to solve this problem. The problem does not occur when using Netscape or Mozilla. Are there some type of buffer limits in IE, and how od I get around them?

Note, when I put in an "alert" statement in my JS code in the middle of the document (marked by ************
for clarity) creation the problem "goes away" in IE. I try to intermittently open and close the document to try and break the buffer, but it does not help.

Any help would be appreeciated.

Thanks...Larry

1. Opening a new window, using the method window.open
2. The following is a code bit:

test = window.open('','ASSESSMENT',
'toolbar=no,width=640,height=480,status=no,scrollbars=yes,resizable=yes,menubar=no');
//window.focus();

with (test.document)
{
open();
write('<html>\n<head>\n' + '<title>GoToLearn ' + formID + ' Assessment</title>\n');

write('<script language="JavaScript" src="resources.js">\n' + '</script>\n');

write('<style type="text/css">\n' +
'input \n' +
'{\n' +
'font-size: 14px;\n' +
'font-family: "Arial", "Helvetica", sans-serif;\n' +
'color: #000000;\n' +
'}\n' +
'td\n' +
'{\n' +
'font-size: 14px;\n' +
'font-family: "Arial", "Helvetica", sans-serif;\n' +
'color: #000000;\n' +
'}\n' +
'h3\n' +
'{\n' +
'font-size: 18px;\n' +
'font-family: "Arial", "Helvetica", sans-serif;\n' +
'color: #000000;\n' +
'}\n' +
'.control\n' +
'{\n' +
'font-size: 14px;\n' +
'font-family: "Arial", "Helvetica", sans-serif;\n' +
'background-color: #ffff00;\n' +
'color: #000000;\n' +
'}\n' +
'</style>\n' +
'</head>\n');

write('<body bgcolor="#ddffdd">\n');

// document container table
write('<table width="610" >\n' +
'<tr>\n' +
'<td >\n' +
'<table cellspacing="0" cellpadding="0">\n' +
'<tr>\n' +
'<td width="150" height="85">\n' +
'<img src="logo.gif" width="140" >\n' +
'</td>\n' +
'<td align="center" width="400">\n' +
'<b>\n' +
'Click the Submit button after<br>\n' +
'you have completed the assessment.<br><br>\n' +
'Click the Formulas button for<br>\n' +
'formulas and conversions.\n' +
'</b>\n' +
'</td>\n' +
'<td align="center" width="90">\n' +
'<font size="-1">' + formID + '</font><br>' +
'<form>\n' +
'<input type=button class="control" value="Submit" onclick="javascript:opener.gradeTest();">\n' +
'<input type=button class="control" value="Formulas" onclick="javascript:opener.displayFormula();">\n' +
'</form>\n' +
'</td>\n' +
'</tr>\n' +
'</td colspan="2">\n' +
'</table>\n' +
'<hr>\n');

//************* alert("here we are"); ***************//

for (var i = 0; i < numberToPresent; i++)
{
index = shuffledOrder[i];
write('<h3>Problem \n' + (i + 1) + ' of \n' + numberToPresent + '</h3>\n' +
// Outer one-problem table
'<table width="100%" cellspacing="0" cellpadding="0">\n' +
'<tr>\n' +
// left main cell
'<td width="400" valign="top">\n' +
'<b>\n' +
'</b><br>\n' +
'<img src="../GRAPHICS/' + problems[index].graphicPath + '"> \n' +
'<br>\n' +
'<img src="../GRAPHICS/placeholder.gif"> \n' +
'</td>\n' +
// end left main cell

// right main cell
'<td align="center" valign="center">\n' +
'<form>\n');

// answer table
write('<table width="100%" >\n' +
// empty row: helps format; room for another element . . .
'<tr><td colspan="4"><br></td></tr>\n' +
// 'A' choice
'<tr><td><br></td><td width="5%"><b>A.</b></td><td width="5%">\n' +
'<input type=radio name="answer' + index + '" value="A"\n' +
'onClick="javascript:opener.answers[' + index + '] = this.value;"></td>\n' +
'<td width="90%"><br></td></tr>\n' +
// 'B' choice
'<tr><td><br></td><td><b>B.</b></td>\n' +
'<td><input type=radio name="answer' + index + '" value="B"\n' +
'onClick="javascript:opener.answers[' + index + '] = this.value;"></td>\n' +
'<td><br></td></tr>\n' +
// 'C' choice
'<tr><td><br></td><td><b>C.</b></td>\n' +
'<td><input type=radio name="answer' + index + '" value="C"\n' +
'onClick="javascript:opener.answers[' + index + '] = this.value;"></td>\n' +
'<td><br></td></tr>\n' +
// 'C' choice
'<tr><td><br></td><td><b>D.</b></td>\n' +
'<td><input type=radio name="answer' + index + '" value="D"\n' +
'onClick="javascript:opener.answers[' + index + '] = this.value;"></td>\n' +
'<td><br></td></tr>\n' +
'</table>\n' +
// end answer table

'</form>\n' +
'</td>\n' +
// end right main cell

'</tr>\n' +
'</table><!-- outer table -->\n' +
// end outer table
'<hr>\n');
}

write('</td>\n' +
'</tr>\n' +
'</table>\n' +
// end container table
'</body></html>\n');

close();

}

[edited by: tedster at 7:52 pm (utc) on April 17, 2003]

 

rainborick




msg:1476632
 8:52 pm on Apr 17, 2003 (gmt 0)

I had a similar problem when working with a pop-up, but I'm not sure if it affects you. I was working on a pop-up that was used to display a graphic that was stored in an .htaccess-protected directory. The problem I ran into was that with MSIE, the pop-up wouldn't get anything written to it unless I passed a parameter from the pop-up back to the parent via <body onload="opener.function(myVar);"> - which was my solution, but I don't know to this day what the problem was or why this solves it. The thing that strikes me about your sample code is that you might well find it easier to develop and maintain this project if you put the essential/static <HTML> into a real file on your site rather than always generate the window's contents entirely via JavaScript. Just a thought. Good luck!

ShawnR




msg:1476633
 4:53 am on Apr 18, 2003 (gmt 0)

I haven't reviewed your code thoroughly, but my guess is that your Javascript is trying to access an attribute of some element of the new pop-up, before that element has been created. Using the alert() gives the pop-up some time to catch up.

I'd suggest you review the code to figure out what attribute is offending (or move the debug alert() call progressively lower to find out), then put the code that accesses the element in an onload() function for the new pop-up.

Shawn

DrDoc




msg:1476634
 5:29 am on Apr 18, 2003 (gmt 0)

Just wanted to Welcome [webmasterworld.com] you to Webmaster World! ;)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved