//剔除不需要打印的部分
function Contrarypreview() {
bdhtml = document.body.innerHTML;
sprnstr = "";
eprnstr = "";
var tophtml = bdhtml.substr(0, bdhtml.indexOf(sprnstr));
var bothtml = prnhtml.substring(bdhtml.indexOf(eprnstr)+15);
document.body.innerHTML = tophtml + bothtml;
document.execCommand("print");
}
function preview() {
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();
}```
已测试
function print4() {
var headhtml = document.getElementById(“head”).innerHTML;
//alert(headhtml);
var headstr = “” + headhtml + ““;
var footstr = ““;
var printData = document.getElementById(“dvData”).innerHTML; //获得 div 里的所有 html 数据
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr + printData + footstr;
//window.print();
document.execCommand(“print”);
//document.body.innerHTML = oldstr;
return false;
}
function print2() {
document.execCommand(“print”);
}
function print3() {
window.print();
}
function print5() {
(‘#Div1’).attr(“style”,”display:none;”);
document.execCommand(“print”);(‘#Div1’).attr(“style”, “display:block;”);
}
“`
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net