Created
September 30, 2020 12:43
-
-
Save maxflex/18597258c98aa4228b773d4696160018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Печать дива. | |
* | |
*/ | |
function printDiv(id_div) { | |
var contents = document.getElementById(id_div).innerHTML; | |
var frame1 = document.createElement("iframe"); | |
frame1.name = "frame1"; | |
frame1.style.position = "absolute"; | |
frame1.style.top = "-1000000px"; | |
document.body.appendChild(frame1); | |
var frameDoc = frame1.contentWindow | |
? frame1.contentWindow | |
: frame1.contentDocument.document | |
? frame1.contentDocument.document | |
: frame1.contentDocument; | |
frameDoc.document.open(); | |
frameDoc.document.write("<html><head><title>Ателье «Талисман»</title>"); | |
frameDoc.document.write( | |
"<style type='text/css'>\ | |
h4 {text-align: center}\ | |
p {text-indent: 50px; margin: 0}\ | |
</style>" | |
); | |
frameDoc.document.write("</head><body>"); | |
frameDoc.document.write(contents); | |
frameDoc.document.write("</body></html>"); | |
frameDoc.document.close(); | |
setTimeout(function () { | |
window.frames["frame1"].focus(); | |
window.frames["frame1"].print(); | |
document.body.removeChild(frame1); | |
}, 500); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment