Js Onlayoutcomplete

Hi all,

This is my code:

<!--#include file="Session.vbs"-->

<%'@ Language=VBScript CodePage=65001 %>
<%'Option Explicit%>
<HTML XMLNS:IE>
<HEAD>
<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">
<STYLE TYPE="text/css">
.masterstyle
{
margin:0px;
}
</STYLE>
</HEAD>
<body ONLOAD="InitAll()">
<%dim inDoc, xmlOut, rootNode, bodyNode, outDoc, pagesNum
pagesNum = 1

set inDoc = Server.CreateObject("Microsoft.XMLDOM")
set outDoc = Server.CreateObject("Microsoft.XMLDOM")

set rootNode = CreateHeader(inDoc)
set bodyNode = AppendChild(inDoc, rootNode, "body")

//fill indoc

xmlOut = ProcessStr(inDoc.xml)
outDoc.loadXML(xmlOut)
%>
<!--#include file="BlaBla.asp"-->
<SCRIPT LANGUAGE="JavaScript">

function InitAll()
{
AddFirstPage();
Init();
}

function AddFirstPage()
{
newHTML = "<IE:DEVICERECT ID='devicerect1' MEDIA='print' CLASS='masterstyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='document'" +
" ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect2'/>";
newHTML += "</IE:DEVICERECT>";

devicecontainer.insertAdjacentHTML("afterBegin", newHTML);
}

function onPageComplete()
{
var pagesNum = <%=pagesNum%>;
if (event.contentOverflow) {
document.all("layoutrect" + pagesNum).onlayoutcomplete = null;
newHTML = "<IE:DEVICERECT ID='devicerect" + (pagesNum + 1) +
"' MEDIA='print' CLASS='masterstyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect" + (pagesNum + 1) +
"' ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect" + (pagesNum + 2) + "/>";
newHTML += "</IE:DEVICERECT>";

devicecontainer.insertAdjacentHTML("beforeEnd", newHTML);
<%pagesNum = pagesNum + 1%>;
}
}

</SCRIPT>
<DIV ID="devicecontainer">
<!-- Pages created on the fly go here. -->
</DIV>
</BODY>
</HTML>

(My goal is to control the printing)
Problem is ONLAYOUTCOMPLETE doesn't fire although the blabla.asp is 2 pages length...
Any ideas?
[2647 byte] By [amirt] at [2007-11-19 21:43:08]