复制代码 代码如下: 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 = "<html><head></head><body>"; var footstr = "</body>"; 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解析与序列化json数据(三)json的解析探讨
这一节我们主要讨论json的解析。 JSON.parse()方法也可以接收另一个参数,该参数是一个函数,将早每个键值对上调用。为了区别JSON.stringify()接收的替换(过滤)函数(replacer),这个函数被称作还原函数(reviv>>>详细阅读
本文标题:JS打印gridview实现原理及代码
地址:http://www.17bianji.com/kaifa2/JS/22396.html
1/2 1