Click to See Complete Forum and Search --> : using document.writeln() with cached script causes lock up


Michael Shutt
05-30-2001, 12:54 PM
I am trying to create a new document window thru jscript and am running into
a problem adding a cached script tag to the document.

For example, the following javascript is called from a browser window:

function Test()
{
var oWindow = window.open("", "_blank");
oWindow.document.open();
oWindow.document.writeln("<html><head></head>");
oWindow.document.writeln("<scr" + "ipt language=\"JScript\"
src=\"Test.js\">");
oWindow.document.writeln("</scr" + "ipt>");
oWindow.document.writeln("<body>This is a test</body></html>");
oWindow.document.close();
}

This script should load a new browser window that contains an html document
which contains a script tag with a src element (a cached script). But, I am
having problems. I have found the following to be true:

1.) If I embed the script directly (don't use the src attribute), the window
loads correctly.

2.) If I use the src attribute, the window sometimes hangs and never
renders.
a.) If I am accessing the web server locally (a LAN connection), it hangs
about 10% of the time.
b.) If I am accessing the web server remotely (a dialup connection), it
hangs 100% of the time.

3.) If the newly opened window hangs, so does its opener (the window that
contains the test() function).

3.) I can tell from the server log that the new window requests the test.js
file from the server before it hangs.

4.) All of this is the same for IE5.01 and IE5.5 on Windows98 and Win2K.

Has anyone else seen this and/or know what might be going on?



--
Michael Shutt

Please respond to newsgroup as I will not return direct emails.

Russell Jones
05-31-2001, 03:01 PM
I've seen similar problems before. Here are some things to try. Instead of
using the document.writeln commands, build a page on the server that
contains the script or script reference. When you open the new window, have
it navigate to the server page and the script will load correctly. Be sure
to wait until the readyState is complete. After the window is ready and
loaded, you can access the DOM to insert content.

Russell Jones
Sr. Web Development Editor,
DevX.com


"Michael Shutt" <mshutt@mediaone.net> wrote in message
news:3b15243f$1@news.devx.com...
> I am trying to create a new document window thru jscript and am running
into
> a problem adding a cached script tag to the document.
>
> For example, the following javascript is called from a browser window:
>
> function Test()
> {
> var oWindow = window.open("", "_blank");
> oWindow.document.open();
> oWindow.document.writeln("<html><head></head>");
> oWindow.document.writeln("<scr" + "ipt language=\"JScript\"
> src=\"Test.js\">");
> oWindow.document.writeln("</scr" + "ipt>");
> oWindow.document.writeln("<body>This is a test</body></html>");
> oWindow.document.close();
> }
>
> This script should load a new browser window that contains an html
document
> which contains a script tag with a src element (a cached script). But, I
am
> having problems. I have found the following to be true:
>
> 1.) If I embed the script directly (don't use the src attribute), the
window
> loads correctly.
>
> 2.) If I use the src attribute, the window sometimes hangs and never
> renders.
> a.) If I am accessing the web server locally (a LAN connection), it hangs
> about 10% of the time.
> b.) If I am accessing the web server remotely (a dialup connection), it
> hangs 100% of the time.
>
> 3.) If the newly opened window hangs, so does its opener (the window that
> contains the test() function).
>
> 3.) I can tell from the server log that the new window requests the
test.js
> file from the server before it hangs.
>
> 4.) All of this is the same for IE5.01 and IE5.5 on Windows98 and Win2K.
>
> Has anyone else seen this and/or know what might be going on?
>
>
>
> --
> Michael Shutt
>
> Please respond to newsgroup as I will not return direct emails.
>
>
>