- 部分打印的插件有
jquery.PrintArea.js:下载地址
或者
jqprint:下载地址
- 利用 ActiveXObject 设置去除页眉页脚,IE7、8有效;
但是需要IE的 activeX 设置允许未认证的sctiveX 提示,所以如果浏览器设置禁止,就不能生效,出现错误提示。设置了提示,就会弹出是否安装activeX,点是,才能生效。
var hkey_root,
hkey_path,
hkey_key
hkey_root = "HKEY_CURRENT_USER"
hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
// 设置页眉页脚为空
function PageSetup_Null() {
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 doPrint() {
PageSetup_Null();
//打印事件
$('#printarea').printArea();
//或者
$('#printarea').jqprint();
}
