There soon creeps in the misconception of already knowing before you knowGeorg Wilhelm Friedrich Hegel
Relates to DOM Scripting and Firefox and Co
Sometimes when visiting a site in Firefox I have found the page suddenly stops loading, is replaced by a blank screen, and, the status bar displays the text stopped. More often than not this is supplemented by an error thrown in Javascript for an undeclared variable. Well, as frustrating as this is on other sites, the same problem started occurring in the latest build I am working in. After a little code debugging, the error comes down to the use of the document.write method during page loading. I was using this method to declare some inline styles dynamically only if scripts are enabled - following the same prinicples outlined in the article I wrote on Accessible DHTML.
The fix seems to be to create the inline styles with the DOM regardless of the document being served as application/xhtml+xml mime type (in this case it was not). Since the head element is already in place when the external script is called, the inline styles can safely be appended:
if (document.getElementById && document.createElementNS) {
var elem=document.createElementNS("http://www.w3.org/1999/xhtml","style");
elem.setAttribute("type","text/css");
var text=document.createTextNode(strCSS);
elem.appendChild(text);
document.getElementsByTagName("head")[0].appendChild(elem);
} else {
strCSS = '<style type="text/css">' + strCSS + '</style>';
document.write(strCSS);
}
Posted on Sunday, Oct 10, 2004 at 15:40:22.
Comments on Firefox Status: stopped (0)