Put the following files on a Web server to demonstrate the
workaround and the reproduction for each example. After you save all eight
individual files, view the Start.htm Web page, and then follow the instructions
to start the sample code. Replace
Myserverdirectory in
Test3.asp with the path that contains the Repro.xml and Repro.xsl
files.
Repro.xml<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="repro.xsl"?>
<root>
<name>MyFrame</name>
</root>
Repro.xsl<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="javascript">
<xsl:template match="/">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JScript">
<xsl:comment><![CDATA[
function MyOnBeforeUnload()
{
alert("MyOnBeforeUnload");
}
]]></xsl:comment></SCRIPT>
</HEAD>
<BODY onbeforeunload="MyOnBeforeUnload()">
My XML/XSL document
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Start.htm<FRAMESET ROWS="10%, *">
<FRAME scrolling="no" SRC="about:blank">
<FRAME scrolling="no" SRC="startbottom.htm">
</FRAMESET>
Startbottom.htm<html>
<body>
bottom frame
<br>
<br>
<br>
Tests (for each test, click the link and then hit the back button or close the new window).<br>
<br>
<a href="Repro.xml" target="_top">How it should work</a>
<br>
<a href="Repro.xml">Repro</a><br>
<br>
<a href="Test1.htm">Workaround 1</a> - Put all XML stuff except onbeforeunload in an iframe<br>
<br>
<a href="Repro.xml" target="newwindow">Workaround 2</a> - Open a new window<br>
<br>
<a href="Test3.asp">Workaround 3</a> - Use ASP<br>
Perform the XML->HTML transform on the server side and stream the HTML file.</body>
</html>
Test1.htm<HTML>
<HEAD>
<script language="jscript">
function MyOnBeforeUnload()
{
alert("MyOnBeforeUnload");
}
</script>
</head>
<body leftMargin=0 rightMargin=0 topMargin=0 bottomMargin=0 onbeforeunload="MyOnBeforeUnload()">
<iframe frameBorder=0 width="100%" height="100%" scrolling="no" src="test1.xml"></iframe>
</body>
</HTML>
Test1.xml<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>
<root>
<name>MyFrame</name>
</root>
Test1.xsl<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="javascript">
<xsl:template match="/">
<HTML>
<BODY>
My alternative XML/XSL document
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Test3.asp<%
Response.ContentType = "text/html"
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
Set xslDoc = Server.Createobject("Microsoft.XMLDOM")
xmlDoc.Load("C:\\Myserverdirectory\\repro.xml")
xslDoc.load("C:\\Myserverdirectory\\repro.xsl")
Response.Write xmlDoc.transformNode(xslDoc)
%>