In this bellow program if you click on ‘PRINT’, the html content of will be added to new popup window called b.html. It is working fine, but b.html has some html content and i am losing this data when new popup window opened. Without missing html content of b.html how can i append new html content inside .
My Sample Code:
Page Name: a.html
<html>
<head>
<script type="text/javascript" src="js/jquery-1.6.1.min.js"> </script>
<script type="text/javascript">
$(document).ready(function()
{
$("#print").click(function()
{
var newWind=window.open('b.html', 'Print message',"left=100,screenX=200,menubar=yes, width=980,height=500, location=yes,resizable=yes,scrollbars=yes,status=yes");
var printableHTML=$("#msg").html();
newWind.document.write(printableHTML);
//newWind.append(printableHTML);
});
});
</script>
</head>
<body>
<span id="print"><u>PRINT</u></span>
<div id="msg">
<h4> I am printing this message...</h4>
</div>
</body>
</html>
Page Name: b.html
<html>
<head> </head>
<body>
<h4>Hello</h4>
<div id="target"></div>
</body>
</html>
By using
document.writeafter the page has loaded, you are replacing the document.Use load event of the window, so that you can access the content of the document once it has loaded: