900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > window.print()打印时 如何自定义页眉/页脚 页边距

window.print()打印时 如何自定义页眉/页脚 页边距

时间:2019-06-16 13:29:47

相关推荐

window.print()打印时 如何自定义页眉/页脚 页边距

自定义页眉/页脚、页边距,要用到ActiveX控件(在ie的安全设置的启用),会修改注册表中ie的设置,代码如下。

try{ var hkey_root,hkey_path,hkey_key; hkey_root="HKEY_CURRENT_USER"; hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";var RegWsh = new ActiveXObject("WScript.Shell");//设置页眉/脚的字体样式hkey_key="font";RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"font-size: 12px; font-family: 黑体; line-height: 24px");//设置页眉hkey_key="header";RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"打印编号");//设置页脚hkey_key="footer"; RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&b第 &p 页/共 &P 页"); //设置页边距(0.6 要乘以 2.5为实际打印的尺寸)hkey_key="margin_bottom"; RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.6");hkey_key="margin_left"; RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.6");hkey_key="margin_right";RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.6"); hkey_key="margin_top";RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.6");window.print();}catch(e){alert(e.name+" "+e.message);}

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