Javascript: Print preview window
July 25, 2008
I would like to create a print preview window that will display only the main content of the page that a person would really want to print. It can work fine on IE and Firefox..You can test other browser.
<html>
<head>
<title>Testing Print Preview</title>
<script LANGUAGE=”JavaScript”>
function displayHTML(printContent) {
var inf = printContent;
win = window.open(“print.htm”, ‘popup’, ‘toolbar = no, status = no’);
win.document.write(inf);
win.document.close(); // new line
}
</script>
</head>
<body>
<div id=”printarea”>Print this stuff.</div>
<a href=”javascript:void(0);” onclick=”displayHTML(printarea.innerHTML)”>Print Preview</a>
</body>
</html>
Don’t forget create print.htm within blank content.
Thanks
CongNguyen
Entry Filed under: Javascript. Tags: Javascript.
Trackback this post | Subscribe to the comments via RSS Feed