Question:
利用瀏覽器本身列印的功能,
將網頁上的某一區段(div、table...等等)輸出。
將網頁上的某一區段(div、table...等等)輸出。
Solve:
function printBlock(htmlBlock) {
var content = htmlBlock.innerHTML;
var printPage = window.open("", "printPage", "");
printPage.document.open();
printPage.document.write("<HTML><head>");
printPage.document.write("</head><BODY onload='window.print();window.close()'>");
printPage.document.write(content);
printPage.document.close("</BODY></HTML>");
}
var content = htmlBlock.innerHTML;
var printPage = window.open("", "printPage", "");
printPage.document.open();
printPage.document.write("<HTML><head>");
printPage.document.write("</head><BODY onload='window.print();window.close()'>");
printPage.document.write(content);
printPage.document.close("</BODY></HTML>");
}
0 意見:
張貼留言