Hi,

I have an html page with a form that allows people to select a variable number from a drop down and click "Add", this calls my client side Javascript function which document.write's (using jQuery) the selected amount of HTML blocks to the page. Inside each block is a Javascript function which needs to execute when it has been written.

This is the function that returns the code to be written to the page
Code:
function writeBlock(iterations) {
   xhtml_code = '';
   for (i = 0; i < iterations; i++) {
             xhtml_code += '<div class="loading"><img src="/img/loading.gif" style="border:0px;"> <em>Loading</em></div>';
             xhtml_code += '<script language="javascript">';
             xhtml_code += 'eval(alert(\'asdas\'));';
             xhtml_code += '</script>';
             xhtml_code += '</div>';
   }
   return xhtml_code;
}
I have put in an alert there for debugging, it would usually be an Ajax call - I have tried it with and without the eval() statement too.

The function calls this onclick of the submit button and does a jquery:
Code:
$(xhtml_code)
    .appendTo('#div-container');
Which basically document.write's it to the div container div.

Now this works perfectly in Firefox, but in IE (6/7) it completely ignores the Javascript (not even an error) and in Safari it does the same.

Any ideas?