//设置网页打印的页眉页脚为空
function pagesetup_Null() {
var hkey_root, hkey_path, hkey_key;
hkey_root = "HKEY_CURRENT_USER"
hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
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 print() {
//获取要打印的dom
var js_Element = document.getElementById("tb_Main");
//bdhtml = window.document.body.innerHTML;
//sprnstr = "<!--startprint-->";
//eprnstr = "<!--endprint-->";
//prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
//prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
var newwin = window.open("tmp.html", "", "height=768,width=1024");
newwin.document.open("text/html", "replace");
newwin.document.write('<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
newwin.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
newwin.document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
newwin.document.write('<link id="print" href="/css/print.css" rel="stylesheet" type="text/css" />');
newwin.document.write('<title></title></head><body>');
newwin.document.write(js_Element.outerHTML);
//newwin.document.body.innerHTML = prnhtml;
newwin.document.write('</body></html>');
newwin.document.close();
newwin.document.getElementById("print").href = "/css/print.css";
//打印内容调整...
pagesetup_Null(); //设置网页打印的页眉页脚为空
newwin.print();
newwin.close();
}