document.write error in Javascript executed on HTML output by XSLT

[email protected] (Steven Bethard)
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization http://groups.google.com
Message-ID <[email protected]>
Sorry if this has been answered already somewhere -- I searched Google
groups and couldn't find the answer, but maybe I was searching for the
wrong things...  Feel free to send a pointer if the answer's already
out there.

I get the following error when calling document.write from Javascript
on a HTML page generated with XSL from an XML document:

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004003 (NS_ERROR_INVALID_POINTER)
[nsIDOMNSHTMLDocument.write]"  nsresult: "0x80004003
(NS_ERROR_INVALID_POINTER)"  location: "JS frame ::
http://ucsu.colorado.edu/~bethard/ucsu.js :: writePersonalMenu :: line
152"  data: no]

I start with the document:

http://ucsu.colorado.edu/~bethard/recipes/bruschetta.xml

which is linked to the XSL stylesheet:

http://ucsu.colorado.edu/~bethard/style/recipe.xsl

The stylesheet generates the following html (among other things):

<!-- BEGIN SIDEBAR -->
<script src="../ucsu.js"/>
<script type="text/javascript">writePersonalMenu()</script>
<!-- END SIDEBAR -->

The javascript in

http://ucsu.colorado.edu/~bethard/ucsu.js

looks like:

function writePersonalMenu() {
        ...
	document.write(
		'<div id="sidebar">\n' +
		'<h1>SITE</h1>\n' +
		rootNode.toString(current) +
		'<a class="switch-site" href="' + current.pathToRoot +
		'index.html">My Professional Site</a>' +
		'</div>'
	);
}

So, basically the idea is that the XML gets transformed to HTML by the
XSL stylesheet, and then the Javascript operates on the HTML document
to add the sidebar.  As far as I can tell, I get the error every time
I hit the document.write call.

The Javascript runs as I would expect in IE (generating the sidebar
for the webpage), but in Firefox, I get a blank page and the error I
mentioned above.  How can I get Firefox to display my sidebar
correctly?

Thanks,

Steve
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.