我不知道这是否是您要查找的内容,但是您可以从 IE 打开打印对话框并从 activex 控件中预定义一些值并删除页面的页脚和页眉,并根据需要设置页边距
function printSpecial() {
try {
var html = '<HTML><HEAD>\n';
if (document.getElementsByTagName != null) {
var headTags = document.getElementsByTagName('head');
if (headTags.length > 0)
html += headTags[0].innerHTML;
}
html += '<BODY style="background-color: #ffffff;">\n';
var printReadyElem = document.getElementById('content');
if (printReadyElem != null) {
html += printReadyElem.innerHTML;
}
else {
alert('Could not find the printReady function');
return;
}
html += '</BODY></HTML>';
shell = new ActiveXObject("WScript.Shell");
shell.sendKeys('%fu'); //brings up page setup
shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{TAB}0{TAB}0{TAB}{UP}{TAB}{UP}{TAB}{UP}{UP}{UP}{UP}{TAB}{UP}{UP}{ENTER}");
window.setTimeout("shell.SendKeys('%fp')",1000); // brings up print dialog
} catch (e) {
alert ("An exception occured: " + e + "\nCode is: " + e.number + "\nDescription is: " + e.description);
alert('Please verify that your print settings have a Landscape orientation.');
}
}