Created
June 13, 2019 01:52
-
-
Save cave2006/b407adc9d63621b9b1fd0f10a18ec03e 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
<script> | |
jQuery(function($){ | |
$('#print').click(function(){ | |
var printing_css='<style media=print>#to_print {display: block}</style>'; | |
var html_to_print=printing_css+$('#to_print').html(); | |
var iframe=$('<iframe id="print_frame">'); | |
$('body').append(iframe); | |
var doc = $('#print_frame')[0].contentDocument || $('#print_frame')[0].contentWindow.document; | |
var win = $('#print_frame')[0].contentWindow || $('#print_frame')[0]; | |
doc.getElementsByTagName('body')[0].innerHTML=html_to_print; | |
win.print(); | |
$('iframe').remove(); | |
}); | |
}); | |
</script> | |
<style>#to_print {display:none;}</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment