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

  • Home
  • SEARCH
  • 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 536541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:49:58+00:00 2026-05-13T09:49:58+00:00

I got a portion of javascript code embedded in HTML (generated on the server

  • 0

I got a portion of javascript code embedded in HTML (generated on the server side) that looks like this:

function winWriteMail2(){
  var win = open('','wininfo', 'width=400,height=300,scrollbars=yes,resizable=yes');
  win.document.open();
  win.document.write('<HTML><HEAD><META http-equiv="Content-type" content="text/html; charset=iso-8859-2"><LINK rel="stylesheet" type="text/css" href="/css/main.css">');
  win.document.write('<scr' + 'ipt language="javascript" type="text/javascript" src="/js/JSFILE.js"></scr' + 'ipt>');
  win.document.write('</HEAD><BODY BGCOLOR="#f7f3e7">');
  <!-- window content goes here -->
  win.document.write('</BODY></HTML>');
  win.document.close();
}

This code gets executed on click of a element.

The problematic part for me is the inclusion of javascript file – it works ok in Firefox and Chrome, but IE (7 and 8, as I tested) behaves strange. With the line containing JSFILE there, the window on click gets opened, but is empty, CPU is 100% busy and only way is to kill IE.

Anyone can help with handling this problem? Maybe I should use some other way to insert the javascript files in there?

I tried, instead of win.document.write(), the DOM-manipulation method, putting this part of code after win.document.close():

h = win.document.getElementsByName('head')[0];
js = document.createElement('script');
js.src = '/js/JSFILE.js';
h.appendChild(js);

but then the code isn’t loaded, even in Firefox (and inspecting with firebug doesn’t show it even can see it).


After some checks, I found out that the problem is caused by <script> elements with a src= attribute defined. If I add an inline script, like:

<script type='text/javascript'>alert('foo')</script>

within my document.write(), the window opens, the alert box shows up and everything’s all right.

But using a

<script type='text/javascript' src='/js/foo.js'></script>

IE stalls when opening the new window, keeps using 100% of CPU.

  • 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-13T09:49:58+00:00Added an answer on May 13, 2026 at 9:49 am

    This code worked for me:

    function winWriteMail2(){
        var win = open('','wininfo', 'width=400,height=300,scrollbars=yes,resizable=yes');
        win.document.open();
        win.document.write('<HTML><HEAD><META http-equiv="Content-type" content="text/html; charset=iso-8859-2"><LINK rel="stylesheet" type="text/css" href="/css/main.css">');
        win.document.write('</HEAD><BODY BGCOLOR="#f7f3e7">');
        win.document.write('this is the body content');
        win.document.write('</BODY></HTML>');
        win.document.close();
    
        var h = win.document.getElementsByTagName("head")[0];
        var js = win.document.createElement("script");
        js.type = "text/javascript";
        js.src = "js/scriptfile.js";
        h.appendChild(js);
    }
    

    Here is what I needed to change in your code to make it work:

    //From
    var js = document.createElement("script");
    //To
    var js = win.document.createElement("script");
    

    You need to create the script element in the same document that you are appending.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 307k
  • Answers 308k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to check whether a result tree fragment… May 13, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer Understand peer-to-peer or star-topology network programming and probably drawing 2D… May 13, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer I would consider a lightweight framework such as http://werkzeug.pocoo.org/ as… May 13, 2026 at 9:37 pm

Related Questions

I've got a big project written in PHP and Javascript. The problem is that
I am having the strangest issue with a site i am developing. On the
Still working through JQuery to get data and repopulate portions of a page. Right
My dev environment is LAMP-based (Drupal); there are several JS (jQuery) files that are
I'm wondering if someone can point me in the right direction. I've got an

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.