| 導購 | 订阅 | 在线投稿
分享
 
 
 

JavaScript打印頁面去除頁眉頁腳 VBScriptWEB打印,去頁眉和頁腳

來源:互聯網  2008-09-05 07:10:29  評論

//注冊表路徑

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_key1="header";

hkey_key2="footer";

RegWsh.RegWrite(hkey_root+hkey_path+hkey_key1,"");

RegWsh.RegWrite(hkey_root+hkey_path+hkey_key2,"");

}catch(e)...{}

}

//設置頁眉頁腳爲默認值

function PageSetup_Default()

...{

try...{

var RegWsh = new ActiveXObject("WScript.Shell") ;

hkey_key1="header";

hkey_key2="footer";

RegWsh.RegWrite(hkey_root+hkey_path+hkey_key1,"&w&b頁碼,&p/&P");

RegWsh.RegWrite(hkey_root+hkey_path+hkey_key2,"&u&b&d");

}catch(e)...{}

}

function printReport()...{

PageSetup_Null();//設置頁眉頁腳爲空

window.print();//打印頁面

PageSetup_Default();//設置頁眉頁腳爲默認值

}

1. IE浏覽器. 文件->頁面設置.

把頁腳去掉就行了.

2.用代碼.

//有提示的..

<HEAD>

<TITLE> New Document </TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="YC">

<script language="VBScript">

dim hkey_root,hkey_path,hkey_key

hkey_root="HKEY_CURRENT_USER"

hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"

'//設置網頁打印的頁眉頁腳爲空

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

'//設置網頁打印的頁眉頁腳爲默認值

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頁碼,&p/&P"

hkey_key="\footer"

RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"

end function

</script>

</HEAD>

<BODY>

<br>

<br>

<br>

<br>

<br>

<br><p align=center>

<input type="button" value="清空頁碼" onclick=pagesetup_null()> <input type

="button" value="恢複頁嗎" onclick=pagesetup_default()><br>

</p>

</BODY>

</HTML>

//注冊表路徑 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_key1="header"; hkey_key2="footer"; RegWsh.RegWrite(hkey_root+hkey_path+hkey_key1,""); RegWsh.RegWrite(hkey_root+hkey_path+hkey_key2,""); }catch(e)...{} } //設置頁眉頁腳爲默認值 function PageSetup_Default() ...{ try...{ var RegWsh = new ActiveXObject("WScript.Shell") ; hkey_key1="header"; hkey_key2="footer"; RegWsh.RegWrite(hkey_root+hkey_path+hkey_key1,"&w&b頁碼,&p/&P"); RegWsh.RegWrite(hkey_root+hkey_path+hkey_key2,"&u&b&d"); }catch(e)...{} } function printReport()...{ PageSetup_Null();//設置頁眉頁腳爲空 window.print();//打印頁面 PageSetup_Default();//設置頁眉頁腳爲默認值 } 1. IE浏覽器. 文件->頁面設置. 把頁腳去掉就行了. 2.用代碼. //有提示的.. <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT="YC"> <script language="VBScript"> dim hkey_root,hkey_path,hkey_key hkey_root="HKEY_CURRENT_USER" hkey_path="\Software\Microsoft\Internet Explorer\PageSetup" '//設置網頁打印的頁眉頁腳爲空 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 '//設置網頁打印的頁眉頁腳爲默認值 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頁碼,&p/&P" hkey_key="\footer" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d" end function </script> </HEAD> <BODY> <br> <br> <br> <br> <br> <br><p align=center> <input type="button" value="清空頁碼" onclick=pagesetup_null()> <input type ="button" value="恢複頁嗎" onclick=pagesetup_default()><br> </p> </BODY> </HTML>
󰈣󰈤
王朝萬家燈火計劃
期待原創作者加盟
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有