Zi 字媒體
2017-07-25T20:27:27+00:00
JS自動列印(使用CSS分頁和JavaScript實現局部列印去除網址列)
index.html
網頁舉例
連結到想要分頁列印的網頁
print.html
自動分頁列印!
var iID;
function doPrint()
{
clearTimeout(iID);
bdhtml=window.document.body.innerHTML;
sprnstr=””;
eprnstr=””;
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=””;
history.go(-1);
}
function autoclick()
{
lnk = document.getElementById(“auto”);
lnk.click();
}
function RunTimer()
{
iID=setTimeout(“autoclick();”,100);
}
列印
這是列印的第一頁!
這是列印的第二頁!
寫了
5860316篇文章,獲得
23313次喜歡