Instead of opening a new window without any URL, I opened this page in the window and accessed the contents of the pnlSummary from the opened window via window.opener object –
function CallPrint() {
var winPrint = window.open('Print.aspx', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');
}
On Print.aspx page I used this function –
function Print() {
var prtContent = "<h3>Summary</h3>" + window.opener.document.getElementById('ctl00_cphContent_pnlSummary').innerHTML;
document.getElementById("printDiv").innerHTML = prtContent;
window.print();
window.opener.focus();
window.close(); }
and called it on body onload.
<body onload="Print();">
<form id="form1" runat="server">
<div id="printDiv">
</div>
</form>
</body>
This is working fine in both IE and Firefox.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…