js 设置网页打印的页眉页脚和页边距

Bensonhai Bensonhai 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
本人是用js写,代码如下:
function PageSetup_Null() {
try {
var Wsh = new ActiveXObject("WScript.Shell");
HKEY_Key = "header";
//设置页眉(为空)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
HKEY_Key = "footer";
//设置页脚(为空)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
HKEY_Key = "margin_bottom";
//设置下页边距(0)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_left";
//设置左页边距(0)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_right";
//设置右页边距(0)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_top";
//设置上页边距(8)
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "8");
} catch(e) {
alert("不允许ActiveX控件");
}
}
ActiveXObject("WScript.Shell");这个对象无效,网上的方法我都试过了,都无效
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
Bensonhai
JavaScript 87,984 成员 224,680 内容