I have a print () function on my website that is used to print a specific part of the website. It works great on Firefoxand even on Internet explorer, but doesn't work on chrome. It opens a dialog box and gets the number of pages, but cannot get the content (in chrome).
my code is below:
<a href="#" onclick="PrintElem('#press_releas11')"><img src="images/print_icon.png" width="35" height="23" /></a>
<div class="blog_post" id="press_releas11">
<div class="post_title"><h3>title here</h3></div>
<div class="post_article">content here</div>
</div>
script:
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>PressReleases</title>');
mywindow.document.write('<link rel="stylesheet" href="css/main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('data');
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.focus();
mywindow.print();
mywindow.close();
return true;
}
</script>
source
share