Forum Moderators: open

Message Too Old, No Replies

document.write() in firefox

document.write() as used via xslt in the html rendering process

         

whiskeyGuzzler

11:49 pm on Apr 26, 2006 (gmt 0)



Howdy, i have an issue with firefox rewriting the whole DOM each time document.write is called, heres an example (loading the XML directly into firefox off the desktop) below, in which i wish to have both spans alert their nonsense via the JS file, note if you comment out the document.write(..) line, this will work, else the document.write kills the former <script ... src='firefox.js'..></script> as generated by the <application/> via xslt QUESTION IS how to get the effect of document.write here without firefox barfing, note this stuff works in IE without issue, just firefox has the issue:

XML file (firefox.xml):
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="firefox.xsl"?>

<webPage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<view>

<application />

<span id="foo">#*$!</span>

<span id="bar">yyy</span>

</view>

</webPage>

------------------------
XSL file (firefox.xsl):
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="webPage">
<html>
<head>
<title><xsl:value-of select="@title" /></title>
</head>
<body>

<xsl:apply-templates select="./view"/>

</body>
</html>
</xsl:template>


<xsl:template match="view">

<xsl:apply-templates/>

</xsl:template>

<xsl:template match="span">
<script language="JavaScript">
startX("<xsl:value-of select="@id"/>");
</script>

<xsl:apply-templates/>

<script language="JavaScript">
endX();
</script>

</xsl:template>

<xsl:template match="application">

<script language="JavaScript" type="text/javascript" src="firefox.js"></script>

</xsl:template>

-----------------
JS file (firefox.js):
if (typeof(startX) == "undefined") {
alert('defining');
function startX(p_id) {
alert('startX: ' + p_id);
}
function endX() {
alert('endX');
document.open();
document.write('foo');
}
}

JAB Creations

9:31 am on Apr 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi whiskeyGuzzler and welcome to WebmasterWorld!

I'll need someone to follow my post up as I feel I can only give you a partial but well leading answer.

document.write does not work with application/xhtml+xml mimetype. From what I'm guessing it doesn't work with XSLT either. Again don't go by my word alone on this one.

John