JS打印gridview实现原理及代码_javascript技巧
程序员文章站
2024-02-13 08:43:10
...
复制代码 代码如下:
var hkey_root = "HKEY_CURRENT_USER";
var hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
var hkey_key;
function printPage() {
try {
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key = "header"
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "&w&b页码,&p/&P")
hkey_key = "footer"
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "") //去掉了&u 因为我不想显示当前打印页的网址
hkey_key = "margin_bottom";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.39"); //0.39相当于把页面设置里面的边距设置为10
hkey_key = "margin_left";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.39");
hkey_key = "margin_right";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.39");
hkey_key = "margin_top";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.39");
}
catch (e) { }
var headstr = "";
var footstr = "";
var newWin = window.open('printer', '', '');
var titleHTML = document.getElementById("printdiv").innerHTML;
newWin.document.write(headstr + titleHTML + footstr);
newWin.document.location.reload();
newWin.print();
// newWin.close();
}
推荐阅读
-
JS打印gridview实现原理及代码_javascript技巧
-
js网页中的(运行代码)功能实现思路_javascript技巧
-
JS 实现BASE64_ENCODE和BASE64_DECODE(实例代码)_javascript技巧
-
JavaScript将Table导出到Excel实现思路及代码_javascript技巧
-
Js实现双击鼠标自动滚动屏幕的示例代码_javascript技巧
-
『JavaScript』限制Input只能输入数字实现思路及代码_javascript技巧
-
JavaScript将Table导出到Excel实现思路及代码_javascript技巧
-
js去字符串前后空格5种实现方法及比较_javascript技巧
-
使用JavaScript实现网页版Pongo设计思路及源代码分享_javascript技巧
-
js实现的定时关闭页面或定时提醒效果代码_javascript技巧