<HTML><HEAD><TITLE>web打印去掉页眉页脚,以及不想打印出的页面元素</TITLE>DpALinux联盟
<META http-equiv=Content-Type content="text/html; charset=gb2312">DpALinux联盟
<SCRIPT language=javascript>DpALinux联盟
function printpr() //预览函数DpALinux联盟
{DpALinux联盟
document.all("qingkongyema").click();//打印之前去掉页眉,页脚DpALinux联盟
document.all("dayinDiv").style.display="none"; //打印之前先隐藏不想打印输出的元素(此例中隐藏“打印”和“打印预览”两个按钮)DpALinux联盟
var OLECMDID = 7;DpALinux联盟
var PROMPT = 1; DpALinux联盟
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';DpALinux联盟
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); DpALinux联盟
WebBrowser1.ExecWB(OLECMDID, PROMPT);DpALinux联盟
WebBrowser1.outerHTML = "";DpALinux联盟
document.all("dayinDiv").style.display="";//打印之后将该元素显示出来(显示出“打印”和“打印预览”两个按钮,方便别人下次打印)DpALinux联盟
} function printTure() //打印函数DpALinux联盟
{DpALinux联盟
document.all('qingkongyema').click();//同上DpALinux联盟
document.all("dayinDiv").style.display="none";//同上DpALinux联盟
window.print();DpALinux联盟
document.all("dayinDiv").style.display="";DpALinux联盟
}DpALinux联盟
function doPage()DpALinux联盟
{DpALinux联盟
layLoading.style.display = "none";//同上DpALinux联盟
}
</SCRIPT>
<script language="VBScript">DpALinux联盟
dim hkey_root,hkey_path,hkey_keyDpALinux联盟
hkey_root="HKEY_CURRENT_USER"DpALinux联盟
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"DpALinux联盟
'//设置网页打印的页眉页脚为空DpALinux联盟
function pagesetup_null()DpALinux联盟
on error resume nextDpALinux联盟
Set RegWsh = CreateObject("WScript.Shell")DpALinux联盟
hkey_key="\header" DpALinux联盟
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""DpALinux联盟
hkey_key="\footer"DpALinux联盟
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""DpALinux联盟
end functionDpALinux联盟
'//设置网页打印的页眉页脚为默认值DpALinux联盟
function pagesetup_default()DpALinux联盟
on error resume nextDpALinux联盟
Set RegWsh = CreateObject("WScript.Shell")DpALinux联盟
hkey_key="\header" DpALinux联盟
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"DpALinux联盟
hkey_key="\footer"DpALinux联盟
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"DpALinux联盟
end functionDpALinux联盟
</script>
</HEAD>DpALinux联盟
<BODY background="images/background_01.gif" leftMargin=0 DpALinux联盟
topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%">
<DIV align=center>DpALinux联盟
DpALinux联盟
你希望打印的内容..........DpALinux联盟
</DIV>
<DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打印" onclick="printTure();"> DpALinux联盟
<input type="button" class="tab" value="打印预览" onclick="printpr();">DpALinux联盟
<input type="hidden" name="qingkongyema" id="qingkongyema" class="tab" value="清空页码" onclick="pagesetup_null()"> DpALinux联盟
<input type="hidden" class="tab" value="恢复页码" onclick="pagesetup_default()">DpALinux联盟
</DIV>
</BODY>DpALinux联盟
</HTML>
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论