Re: document.write error in Javascript executed on HTML output by XSLT
Axel Hecht <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
Steven Bethard wrote:
> 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
document.write is not supported in XSLT output.
Axel