Using document.write() after the page has finished loading, implicitly calls document.open() , which creates a new page. Normally you should avoid document.write() and stick to the proper DOM creation methods or use jQuery short string creation methods:
jQuery(function($) { $('<style type="text/css"> .preload img { display: none; } </style>') .appendTo("head"); $('#body-wrap').preloadThis(); });
<h / "> I assume that you cannot edit the HTML or CSS files uploaded by the page to include this rule? If this is the case and you want these styles applied before the page has finished loading, please remove document.write() from the jQuery handler:
// write() before the document finishes loading document.write('<style type="text/css"> .preload img { display: none; } </style>'); jQuery(function($) { $('#body-wrap').preloadThis(); });
This will write the <style> immediately after the current <script> . I hope this is in your <head> element, since <style> not valid anywhere, although all browsers should parse it anyway.
Andy E Dec 23 '10 at 16:12 2010-12-23 16:12
source share