Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 917751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:15:34+00:00 2026-05-15T18:15:34+00:00

I’m running into an issue that seems to only appear on Windows 7. It

  • 0

I’m running into an issue that seems to only appear on Windows 7. It seemed to work fine in IE8 on a different version of Windows. Basically, I’m creating a new window with window.open(), then using document.write() to write the contents of that new window, which contains script includes. In IE, these scripts are not being executed properly. Most of the time they don’t execute at all, but occasionally one of them will. This is only with a cleared cache – once the javascript files are in the cache, it works fine.

Boiled down test case:

test.html:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
   <script type="text/javascript">
      var w = window.open();
      var windowHTML = "\
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n\
<html>\n\
<head>\n\
   <script type='text/javascript' src='test.js'></scr"+"ipt>\n\
   <script type='text/javascript' src='test2.js'></scr"+"ipt>\n\
</head>\n\
<body>\n\
</body>\n\
</html>";
      w.document.write(windowHTML);
      w.document.close();
   </script>
</head>
<body>
</body>
</html>

test.js:

alert("test");

test2.js:

alert("test2");

When I go to test.html, I would expect to see a new window pop up with alerts for “test” then “test2”. I do in most browsers, including IE6. However, when I try this in IE8 on Windows 7, it opens the blank page, but no alerts appear (or occasionally just one).

Is it some sort of timing issue? Has anyone else seen this? Is there some way I can get around it?


Edit:
Here’s the code I tried that Rob Cooney wanted to see. Again, it works in other browsers, but not in IE8 on Windows 7.

test.htm:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
   <script type="text/javascript">
      var w = window.open();
      var windowHTML =
         "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n" +
         "<html>\n" +
         "<head>\n" +
         "   <script type='text/javascript' src='test.js'></scr"+"ipt>\n" +
         "   <script type='text/javascript' src='test2.js'></scr"+"ipt>\n" +
         "</head>\n" +
         "<body onload='test();test2()'>\n" +
         "</body>\n" +
         "</html>";
      w.document.write(windowHTML);
      setTimeout(function() {
         w.document.close();
      }, 10000);
   </script>
</head>
<body>
</body>
</html>

test.js:

function test() {
   alert("test");
}

test2.js:

function test2() {
   alert("test2");
}

Also, I’ve posted this as a question on the MSDN forums here.


Accepting no’s workaround as the best answer. Here’s my modified code:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
   <script type="text/javascript">
      var w = window.open();
      var windowHTML =
         "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n" +
         "<html>\n" +
         "<head></head>\n" +
         "<body></body>\n" +
         "</html>";
      w.document.write(windowHTML);
      w.document.close();

      var s = w.document.createElement("script");
      s.type = "text/javascript";
      s.src = "test.js";
      w.document.getElementsByTagName("HEAD")[0].appendChild(s);

      var s2 = w.document.createElement("script");
      s2.type = "text/javascript";
      s2.src = "test2.js";
      w.document.getElementsByTagName("HEAD")[0].appendChild(s2);
   </script>
</head>
<body>
</body>
</html>

Note: the thing to watch out for with this solution is that the javascript files are now loaded asynchronously, so if you have dependencies between the files, you can’t be sure that they will load in the right order. I got around this with setTimeout and testing for the existence of variables in the first file before loading the second file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:15:35+00:00Added an answer on May 15, 2026 at 6:15 pm

    Try something like this (untested):

    var s=document.createElement('script');
    s.type = "text/javascript";
    s.src = "test.js";
    document.body.appendChild(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.