|
<HTML><HEAD><TITLE>Web printing removes the header and footer, and the page elements that do not want to be printed</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=javascript>
function printpr() //Preview function
{
document.all("qingkongyema").click();//Remove the header and footer before printing
document.all("dayinDiv").style.display="none"; //Hide the elements that you do not want to print before printing (in this example, hide
Hide two buttons "Print" and "Print Preview")
var OLECMDID = 7;
var PROMPT = 1;
var WebBrowser ='<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-
11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.all("dayinDiv").style.display="";//Display the element after printing (showing "printing" and "printing pre
"View" two buttons, convenient for others to print next time)
}
function printTure() //Print function
{
document.all('qingkongyema').click();//Same as above
document.all("dayinDiv").style.display="none";//Same as above
window.print();
document.all("dayinDiv").style.display="";
}
function doPage()
{
layLoading.style.display = "none";//same as above
}
</SCRIPT>
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
'//Set the header and footer of web page printing to be empty
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//Set the header and footer of web page printing as default values
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key, "&w&b page number,&p/&P"
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>
</HEAD>
<BODY background="images/background_01.gif" leftMargin=0
topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%">
<DIV align=center>
What you want to print..........
</DIV>
<DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打
印" onclick="printTure();">
<input type="button" class="tab" value="Print Preview" onclick="printpr();">
<input type="button" name="qingkongyema" id="qingkongyema" class="tab" value="clear page number"
onclick="pagesetup_null()">
<input type="button" class="tab" value="Restore page number" onclick="pagesetup_default()">
</DIV>
</BODY>
</HTML> |
|