<script type="text/javascript">
var hkey_root,hkey_path,hkey_key;
hkey_root="HKEY_CURRENT_USER";
<!--地址的寫法很嚴格的用雙斜槓-->
hkey_path="[url=file://\\Software\\Microsoft\\Internet]\\Software\\Microsoft\\Internet[/url] Explorer\\PageSetup";
//設置網頁打印的頁眉頁腳爲空,頁邊距自定義,打印方向
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="[url=file://\\header]\\header[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="[url=file://\\footer]\\footer[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="[url=file://\\margin_bottom]\\margin_bottom[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.19685");
hkey_key="[url=file://\\margin_top]\\margin_top[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.19685");
hkey_key="[url=file://\\margin_left]\\margin_left[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39370");
hkey_key="[url=file://\\margin_right]\\margin_right[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39370");
hkey_key="[url=file://\\orientation]\\orientation[/url]";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"2");
}catch(e){}
}
function printsetup(){
wb.execwb(8,1); // 打印頁面設置
}
function printpreview(){
wb.execwb(7,1);// 打印頁面預覽
}
function printit() {
if (confirm('確定打印嗎?')) {
wb.execwb(6,1);
}
}
</script>
<!--media=print 這個屬性說明可以在打印時有效-->
<!--希望打印時不顯示的內容設置class="Noprint"樣式-->
<!--希望人爲設置分頁的位置設置class="PageNext"樣式-->
<style media="print">
.Noprint {
display: none;
}
.PageNext {
page-break-after: always;
}
</style>
<style type="text/css">
.STYLE1 {
font-size: 12px
}
</style>
<body>
<OBJECT id="wb" height="0" width="0"
classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>
</body>
注意:路徑要用雙斜槓
通過修改註冊表調用IE內核打印功能實現
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.