Firefox forgets to create document.body object on Linux

If you use client-side XSLT transformations driven by xml-stylesheet pseudo-instruction in XML documents, you might encounter interesting problems when using Firefox 2 on Linux. When the  HTML page is created with XSLT transformation, Firefox does not create the document.body object, causing JavaScript libraries (for example, jQuery) to break.

Workaround: add an ID to your body tag (for example, <body id="body">) and fix the document.body object after the DOM is ready. To do it in jQuery, use the following code:

$(function() {   if (!document.body) document.body = $('#body').get(0); }


Anonymous said...

Found your post while googling for this problem
I am having the same problem in Windows using FF 3.0.10, so apparantly this is not just for Linux, except that your fix does not seem to work for me. Firefox just refuses to create the document.body by assignment.

Ivan Pepelnjak said...

It looks like FF2 for Linux was a slightly different (already broken) build. XSLT in FF3 is so badly broken that I've seriously considered dropping FF3 from my list of supported browsers (but unfortunately that's unrealistic).

Post a Comment