900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > html打印 去除页眉页脚 js客户端打印html并且去掉页眉 页脚

html打印 去除页眉页脚 js客户端打印html并且去掉页眉 页脚

时间:2022-05-10 13:29:43

相关推荐

html打印 去除页眉页脚 js客户端打印html并且去掉页眉 页脚

print()方法用于打印当前窗口的内容,支持部分或者整个网页打印。

调用print()方法所引发的行为就像用户单击浏览器的打印按钮。通常,这会产生一个对话框,让用户可以取消或定制打印请求。

win10下测试ie11、chrome、firefox、360、edge都可以成功去掉页眉页脚;

打印

.printBox {

width: 300px;

height: 300px;

border: 1px solid blue;

}

@page {

size: auto;

margin: 0mm;

}

this is content!!!

点击按钮打印

打印

function print_page() {

if (!!window.ActiveXObject || "ActiveXObject" in window) { //是否ie

remove_ie_header_and_footer();

}

window.print();

}

function remove_ie_header_and_footer() {

var hkey_path;

hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\InternetExplorer\\PageSetup\\";

try {

var RegWsh = new ActiveXObject("WScript.Shell");

RegWsh.RegWrite(hkey_path + "header", "");

RegWsh.RegWrite(hkey_path +"footer", "");

} catch (e) {

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。