Home > Web Front-end > JS Tutorial > JS printing gridview implementation principle and code_javascript skills

JS printing gridview implementation principle and code_javascript skills

WBOY
Release: 2016-05-16 17:42:17
Original
1098 people have browsed it
Copy code The code is as follows:

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&bpage number, &p/&P")
hkey_key = "footer"
RegWsh.RegWrite(hkey_root hkey_path hkey_key, "") //Removed &u Because I don’t want to display the URL of the current printed page
hkey_key = "margin_bottom";
RegWsh.RegWrite(hkey_root hkey_path hkey_key, "0.39"); //0.39 is equivalent to setting the margin in the page settings to 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 = "< ;head>
";
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();
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template