InitClasses();
InitMMarkers();
iDeltaX = 0;
iDeltaY = 0;
bMoveMMarkerLeft = false;
bMoveMMarkerRight = false;
bMoveMMarkerTop = false;
bMoveMMarkerBottom = false; sSrcID = null;
}function FindStyleRule(styleName)
{
for (var i = 0; i < document.styleSheets.length; i++)
{
for (var j = 0; j < document.styleSheets(i).rules.length; j++)
{
if (document.styleSheets(i).rules(j).selectorText == styleName)
return document.styleSheets(i).rules(j);
}
}
}function InitClasses()
{
oPageStyleClass.style.width = printer.pageWidth/100 + "in";
oPageStyleClass.style.height = printer.pageHeight/100 + "in";
oLorStyleClass.style.marginTop = printer.marginTop/100 + "in";
oLorStyleClass.style.marginLeft = printer.marginLeft/100 + "in";
oLorStyleClass.style.width = (printer.pageWidth - (printer.marginLeft + printer.marginRight))/100 + "in";
oLorStyleClass.style.height = (printer.pageHeight - (printer.marginTop + printer.marginBottom))/100 + "in";
oHeaderStyleClass.style.left = printer.marginLeft/100 + "in";
oHeaderStyleClass.style.top = printer.unprintableTop/100 + "in";
oHeaderStyleClass.style.width = oLorStyleClass.style.width;
oFooterStyleClass.style.left = printer.marginLeft/100 + "in";
oFooterStyleClass.style.width = oLorStyleClass.style.width;
oFooterStyleClass.style.top = null;
oFooterStyleClass.style.bottom = printer.unprintableBottom/100 + "in";
}function window::onload()
{
setTimeout(Init, 100);
}function Init()
{
document.attachEvent("onmousedown", MouseDownHandler);
document.attachEvent("onmouseup", MouseUpHandler);
document.attachEvent("onmousemove", MouseMoveHandler);
merLeft.attachEvent("onmousemove", MouseMoveHandler);
merRight.attachEvent("onmousemove", MouseMoveHandler);
merTop.attachEvent("onmousemove", MouseMoveHandler);
AddFirstPage(); zoomcontainer.style.zoom = "75%";
ui.style.width = document.body.clientWidth;
ui.style.height = "40px";
pagecontainer.style.height = document.body.clientHeight - ui.style.pixelHeight;
oPageStyleClass = FindStyleRule(".pagestyle");
oLorStyleClass = FindStyleRule(".lorstyle");
oHeaderStyleClass = FindStyleRule(".headerstyle");
oFooterStyleClass = FindStyleRule(".footerstyle");
oMMarkerClass = FindStyleRule(".mer");
InitClasses();
InitMMarkers();
}function InitMMarkers()
{
merLeft.style.top = oLorStyleClass.style.marginTop;
merRight.style.top = oLorStyleClass.style.marginTop;
merLeft.style.left = oLorStyleClass.style.marginLeft;
merRight.style.left = (printer.pageWidth - printer.marginRight)/100 + "in";
merTop.style.top = oLorStyleClass.style.marginTop;
merBottom.style.top = (printer.pageHeight - printer.marginBottom)/100 + "in";
merTop.style.left = oLorStyleClass.style.marginLeft;
merBottom.style.left = oLorStyleClass.style.marginLeft;
merLeft.style.pixelTop -= 2;
merLeft.style.pixelLeft += 6;
merRight.style.pixelTop -= 2;
merRight.style.pixelLeft += 5;
merTop.style.pixelTop += 6;
merTop.style.pixelLeft -= 2;
merBottom.style.pixelTop += 5;
merBottom.style.pixelLeft -= 2;
}function CheckPrint()
{
switch (dialogArguments.__IE_PrintType)
{
case "Prompt":
if (printer.showPrintDialog())
PrintPrep();
break;
case "NoPrompt":
PrintPrep();
break;
case "Preview":
default:
break;
}
}function PrintPrep()
{
if (oLorStyleClass.style.border = "dashed 1 black") reset = true;
oLorStyleClass.style.border = "dashed 1 white"; if (layoutrect1.contentDocument.readyState == "complete")
{
// This block will be called when printing with user prompt
// because the Print dialog box gives time for the content
// document to complete loading
PrintNow();
}
else
{
// This block will usually be called when printing w/o user prompt
// and sets an event handler that listens for the loading of the content
// document before printing. Sometimes, however, the content document
// will be loaded in time for the previous block to execute
layoutrect1.contentDocument.onreadystatechange = PrintWhenContentDocComplete;
}
if (reset) oLorStyleClass.style.border = "dashed 1 black";
}function PrintWhenContentDocComplete()
{
if (layoutrect1.contentDocument.readyState == "complete")
{
layoutrect1.contentDocument.onreadystatechange = null;
PrintNow();
}
}function PrintNow()
{
var startPage;
var endPage;
var oDeviceRectCollection = document.all.tags("DEVICERECT");
if (dialogArguments.__IE_PrintType == "NoPrompt" ||
printer.selectedPages == false)
{
startPage = 1;
endPage = oDeviceRectCollection.length;
}
else if (printer.currentPage == true)
{
// Determine current page, if necessary.
// Normally, the print current page option is disabled because a print
// template has no way of determining which section of a document is displayed
// in the browser and cannot calculate a current page. In print preview,
// a print template can enable the print current page option because the
// template can determine which page is currently showing in the print
// preview dialog. The print preview window would need a user interface
// with a print button so that the user could print from the print preview
// window. See template7.htm for an example showing how to add a user
// interface to a print preview template.
}
else
{
startPage = printer.pageFrom;
endPage = printer.pageTo;
if (startPage > endPage)
{
alert("Error: Start page greater than end page");
return;
}
if (startPage > oDeviceRectCollection.length)
{
alert("Error: Start page greater than number of pages in print job.");
return;
}
if (endPage > oDeviceRectCollection.length)
{
alert("Warning: End page greater than number of pages in print job. Continuing Print Job.");
endPage = oDeviceRectCollection.length;
}
}
printer.startDoc("Printing from Tmplt6.htm"); for (var i= startPage- 1; i< endPage; i++)
printer.printPage(oDeviceRectCollection[i]);
printer.stopDoc();
}
InitMMarkers();
iDeltaX = 0;
iDeltaY = 0;
bMoveMMarkerLeft = false;
bMoveMMarkerRight = false;
bMoveMMarkerTop = false;
bMoveMMarkerBottom = false; sSrcID = null;
}function FindStyleRule(styleName)
{
for (var i = 0; i < document.styleSheets.length; i++)
{
for (var j = 0; j < document.styleSheets(i).rules.length; j++)
{
if (document.styleSheets(i).rules(j).selectorText == styleName)
return document.styleSheets(i).rules(j);
}
}
}function InitClasses()
{
oPageStyleClass.style.width = printer.pageWidth/100 + "in";
oPageStyleClass.style.height = printer.pageHeight/100 + "in";
oLorStyleClass.style.marginTop = printer.marginTop/100 + "in";
oLorStyleClass.style.marginLeft = printer.marginLeft/100 + "in";
oLorStyleClass.style.width = (printer.pageWidth - (printer.marginLeft + printer.marginRight))/100 + "in";
oLorStyleClass.style.height = (printer.pageHeight - (printer.marginTop + printer.marginBottom))/100 + "in";
oHeaderStyleClass.style.left = printer.marginLeft/100 + "in";
oHeaderStyleClass.style.top = printer.unprintableTop/100 + "in";
oHeaderStyleClass.style.width = oLorStyleClass.style.width;
oFooterStyleClass.style.left = printer.marginLeft/100 + "in";
oFooterStyleClass.style.width = oLorStyleClass.style.width;
oFooterStyleClass.style.top = null;
oFooterStyleClass.style.bottom = printer.unprintableBottom/100 + "in";
}function window::onload()
{
setTimeout(Init, 100);
}function Init()
{
document.attachEvent("onmousedown", MouseDownHandler);
document.attachEvent("onmouseup", MouseUpHandler);
document.attachEvent("onmousemove", MouseMoveHandler);
merLeft.attachEvent("onmousemove", MouseMoveHandler);
merRight.attachEvent("onmousemove", MouseMoveHandler);
merTop.attachEvent("onmousemove", MouseMoveHandler);
AddFirstPage(); zoomcontainer.style.zoom = "75%";
ui.style.width = document.body.clientWidth;
ui.style.height = "40px";
pagecontainer.style.height = document.body.clientHeight - ui.style.pixelHeight;
oPageStyleClass = FindStyleRule(".pagestyle");
oLorStyleClass = FindStyleRule(".lorstyle");
oHeaderStyleClass = FindStyleRule(".headerstyle");
oFooterStyleClass = FindStyleRule(".footerstyle");
oMMarkerClass = FindStyleRule(".mer");
InitClasses();
InitMMarkers();
}function InitMMarkers()
{
merLeft.style.top = oLorStyleClass.style.marginTop;
merRight.style.top = oLorStyleClass.style.marginTop;
merLeft.style.left = oLorStyleClass.style.marginLeft;
merRight.style.left = (printer.pageWidth - printer.marginRight)/100 + "in";
merTop.style.top = oLorStyleClass.style.marginTop;
merBottom.style.top = (printer.pageHeight - printer.marginBottom)/100 + "in";
merTop.style.left = oLorStyleClass.style.marginLeft;
merBottom.style.left = oLorStyleClass.style.marginLeft;
merLeft.style.pixelTop -= 2;
merLeft.style.pixelLeft += 6;
merRight.style.pixelTop -= 2;
merRight.style.pixelLeft += 5;
merTop.style.pixelTop += 6;
merTop.style.pixelLeft -= 2;
merBottom.style.pixelTop += 5;
merBottom.style.pixelLeft -= 2;
}function CheckPrint()
{
switch (dialogArguments.__IE_PrintType)
{
case "Prompt":
if (printer.showPrintDialog())
PrintPrep();
break;
case "NoPrompt":
PrintPrep();
break;
case "Preview":
default:
break;
}
}function PrintPrep()
{
if (oLorStyleClass.style.border = "dashed 1 black") reset = true;
oLorStyleClass.style.border = "dashed 1 white"; if (layoutrect1.contentDocument.readyState == "complete")
{
// This block will be called when printing with user prompt
// because the Print dialog box gives time for the content
// document to complete loading
PrintNow();
}
else
{
// This block will usually be called when printing w/o user prompt
// and sets an event handler that listens for the loading of the content
// document before printing. Sometimes, however, the content document
// will be loaded in time for the previous block to execute
layoutrect1.contentDocument.onreadystatechange = PrintWhenContentDocComplete;
}
if (reset) oLorStyleClass.style.border = "dashed 1 black";
}function PrintWhenContentDocComplete()
{
if (layoutrect1.contentDocument.readyState == "complete")
{
layoutrect1.contentDocument.onreadystatechange = null;
PrintNow();
}
}function PrintNow()
{
var startPage;
var endPage;
var oDeviceRectCollection = document.all.tags("DEVICERECT");
if (dialogArguments.__IE_PrintType == "NoPrompt" ||
printer.selectedPages == false)
{
startPage = 1;
endPage = oDeviceRectCollection.length;
}
else if (printer.currentPage == true)
{
// Determine current page, if necessary.
// Normally, the print current page option is disabled because a print
// template has no way of determining which section of a document is displayed
// in the browser and cannot calculate a current page. In print preview,
// a print template can enable the print current page option because the
// template can determine which page is currently showing in the print
// preview dialog. The print preview window would need a user interface
// with a print button so that the user could print from the print preview
// window. See template7.htm for an example showing how to add a user
// interface to a print preview template.
}
else
{
startPage = printer.pageFrom;
endPage = printer.pageTo;
if (startPage > endPage)
{
alert("Error: Start page greater than end page");
return;
}
if (startPage > oDeviceRectCollection.length)
{
alert("Error: Start page greater than number of pages in print job.");
return;
}
if (endPage > oDeviceRectCollection.length)
{
alert("Warning: End page greater than number of pages in print job. Continuing Print Job.");
endPage = oDeviceRectCollection.length;
}
}
printer.startDoc("Printing from Tmplt6.htm"); for (var i= startPage- 1; i< endPage; i++)
printer.printPage(oDeviceRectCollection[i]);
printer.stopDoc();
}
{
newHTML = "<IE:DEVICERECT ID='page1' MEDIA='print' CLASS='pagestyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='document' ONLAYOUTCOMPLETE='OnRectComplete()' NEXTRECT='layoutrect2' CLASS='lorstyle'/>";
newHTML += "</IE:DEVICERECT>"; zoomcontainer.insertAdjacentHTML("afterBegin", newHTML); headfoot.textHead = printer.header;
headfoot.textFoot = printer.footer;
headfoot.url = dialogArguments.__IE_BrowseDocument.URL;
headfoot.title = dialogArguments.__IE_BrowseDocument.title;
headfoot.page = 1;
AddHeaderAndFooterToPage(1); iNextPageToCreate = 2;
}function OnRectComplete()
{
if (event.contentOverflow == true)
AddNewPage();
else
{
headfoot.pageTotal = document.all.tags("DEVICERECT").length;
for (var i= 1; i<= headfoot.pageTotal; i++)
AddPageTotalToPages(); setTimeout("CheckPrint();", 100);
}
}function OnRectCompleteSimple()
{
if (event.contentOverflow == true) return;
headfoot.pageTotal = parseInt(event.srcElement.parentElement.id.substring(4), 10); AddPageTotalToPages(); ShowFilledPagesAndHideExcessPages();
}function ShowFilledPagesAndHideExcessPages()
{
for (var i= 1; i<= headfoot.pageTotal; i++)
document.all("page" + i).style.position = "static";
var i = headfoot.pageTotal + 1;
while (document.all("page" + i))
{
document.all("page" + i).style.position = "absolute";
i++;
}
}function AddHeaderAndFooterToPage(pageNum)
{
newHeader = "<DIV CLASS='headerstyle'>" + headfoot.htmlHead + "</DIV>";
newFooter = "<DIV CLASS='footerstyle'>" +headfoot.htmlFoot + "</DIV>";
document.all("page" + pageNum).insertAdjacentHTML("afterBegin", newHeader);
document.all("page" + pageNum).insertAdjacentHTML("beforeEnd", newFooter);
}function AddNewPage()
{
document.all("layoutrect" + (iNextPageToCreate - 1)).onlayoutcomplete = OnRectCompleteSimple;
headfoot.page = iNextPageToCreate;
newHTML = "<IE:DEVICERECT ID='page" + iNextPageToCreate + "' MEDIA='print' CLASS='pagestyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect" + iNextPageToCreate + "' ONLAYOUTCOMPLETE='OnRectComplete()' NEXTRECT='layoutrect" + (iNextPageToCreate + 1) + "' CLASS='lorstyle'/>";
newHTML += "</IE:DEVICERECT>"; zoomcontainer.insertAdjacentHTML("beforeEnd", newHTML);
AddHeaderAndFooterToPage(iNextPageToCreate);
headfoot.pageTotal = iNextPageToCreate;
iNextPageToCreate++;
}function AddPageTotalToPages()
{
oSpanCollection = document.all.tags("span");
for (var i= 0; i< oSpanCollection.length; i++)
{
if (oSpanCollection[i].className == "hfPageTotal")
oSpanCollection[i].innerText = headfoot.pageTotal;
}
}function ResizeApp()
{
ui.style.width = document.body.clientWidth;
pagecontainer.style.height = document.body.clientHeight - ui.style.pixelHeight;
}function Zoomer(string)
{
if (string == "in")
{
currZoom = zoomcontainer.style.zoom;
currZoom = currZoom.substring(0, currZoom.length - 1);
currZoom = parseInt(currZoom, 10);
newZoom = currZoom + 1;
if (newZoom > 10000) return;
zoomcontainer.style.zoom = newZoom + "%";
zoomnumber.value = newZoom;
}
else if (string == "out")
{
currZoom = zoomcontainer.style.zoom;
currZoom = currZoom.substring(0, currZoom.length - 1);
currZoom = parseInt(currZoom, 10);
newZoom = currZoom - 1;
if (newZoom < 1) return;
zoomcontainer.style.zoom = newZoom + "%";
zoomnumber.value = newZoom;
}
else
{
if (event.srcElement.id != "zoomnumber") return;
if (event.keyCode != 13) return; var newZoom = zoomnumber.value;
numValue = parseInt(newZoom, 10);
if (numValue != newZoom) return;
if (newZoom > 10000) return;
if (newZoom < 1) return;
zoomcontainer.style.zoom = newZoom + "%";
}
}function DoPageSetup()
{
printer.showPageSetupDialog();
InitClasses();
InitMMarkers();
}function DoPrintFromPreview()
{
if (printer.showPrintDialog())
PrintPrep();
}function ShowHideMargins()
{
if (marginbutton.value == "Show Margins")
{
oMMarkerClass.style.display = "block";
oLorStyleClass.style.border = "dashed 1 black";
marginbutton.value = "Hide Margins";
}
else
{
oMMarkerClass.style.display = "none";
oLorStyleClass.style.border = "dashed 1 white";
marginbutton.value = "Show Margins";
}
}function document.onkeydown()
{
if (event.keyCode == 27)
window.close();
}
</script>
</head><body onresize="ResizeApp()" scroll="no"><tp:templateprinter id="printer" />
<ie:headerfooter id="headfoot" /><div id="ui">
<br style="font-size:7">
<input type="button" value="Page Setup..." onmouseup="DoPageSetup()">
<input type="button" value="Zoom In" onmouseup="Zoomer('in')">
<input id="zoomnumber" type="text" value="75" size="3" maxlength="4" onkeyup="Zoomer('amount')">
<span style="color:white;">%</span>
<input type="button" value="Zoom Out" onmouseup="Zoomer('out')">
<input type="button" value="Print..." onmouseup="DoPrintFromPreview()">
<input id="marginbutton" type="button" value="Hide Margins" onmouseup="ShowHideMargins()">
</div>
<div id="pagecontainer">
<div id="zoomcontainer">
<!-- Dynamically created pages go here. -->
<img id="merLeft" class="mer" src="images/arrow_down.gif" width="10" height="10" border="0">
<img id="merRight" class="mer" src="images/arrow_down.gif" width="10" height="10" border="0">
<img id="merTop" class="mer" src="images/arrow_right.gif" width="10" height="10" border="0">
<img id="merBottom" class="mer" src="images/arrow_right.gif" width="10" height="10" border="0">
<img id="ratioer" class="mer" style="visibility:hidden;left:1in;top:1in" src="images/arrow_right.gif" width="10" height="10" border="0">
</div>
</div></body>
</html>----
scriptX这个组件一定是用这个模板实现
scriptX这个组件一定是用这个模板实现
----------------------------------------------------------------????