方式一:
如果你使用的是IE6以及以前的版本,可以使用這個方法
打開瀏覽器文件->頁面設置
在彈出的頁面設置對話框中,將頁眉輸入框中的"&w&b頁碼,&p/&P"清空則標題信息就不打印了
只去掉&w&b,則只顯示頁碼
將頁腳輸入框中的"&u&b&d"清空就可以了。
只去掉&u,則下面還會顯示打印日期,而不顯示網址。
方式二:
print打印部分網頁,且去掉頁眉、頁腳
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title> </title>
<link rel="stylesheet" type="text/css" id="css" href="http://bbs.blueidea.com/orumdata/cache/style_2.css" />
<Script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
// 設置頁眉頁腳爲空
function PageSetup_Null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell") ;
hkey_key="header" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
hkey_key="footer" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
}
catch(e){}
}
function doPrint(){
PageSetup_Null() ;
var str = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>';
str += '<meta http-equiv="Content-Type" content="text/html; charset=gbk" />';
str += '<title>'+document.title+'</title>';
str += '<link rel="stylesheet" type="text/css" href="http://bbs.blueidea.com/orumdata/cache/style_2.css"
/>';
str +='</head>';
str +='<body οnlοad="window.print()">'+document.getElementByIdx("printarea").innerHTML + '</body></html>';
document.write(str);
document.close();
}
</script>
</head>
<body>
<div id="printarea">
要打印的部分
</div>
<input name="bt" type="button" value="打印" οnclick="doPrint();" />
</body>
</html>
打印整個網頁,不顯示頁面、頁腳
test page print<br>
xxxxxxxxxxx<br>
yyyyyyyyyyyyyy<br>
kkkkkkkkkkkk<br>
<Script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
// 設置頁眉頁腳爲空
function PageSetup_Null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell") ;
hkey_key="header" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
hkey_key="footer" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
}
catch(e){}
}
// 設置頁眉頁腳爲默認值
function PageSetup_Default()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell") ;
hkey_key="header" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b頁碼,&p/&P") ;
hkey_key="footer" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d") ;
}
catch(e){}
}
// 打印
function PrintPage()
{
PageSetup_Null() ;
window.print() ;
PageSetup_Default() ;
}
</Script>
<a href="#" onClick="PrintPage();">Print Page</a>