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. :D

<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: .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Category Cloud

.Net Business HTML & CSS & DOM Javascript PHP Tool

Tags

.Net ADO.NET ajax Business Javascript Oracle ADO.NET Subversion .Net Subversion SVN Source VB.Net

Recent Posts

Archives

Blogroll

Recent Comments

Asaduzzaman Arif on Encrypt/Decrypt string VB…
Pranav on Encrypt/Decrypt string VB…
ntcnet on Encrypt/Decrypt string VB…
Elena on Encrypt/Decrypt string VB…
Elena on Encrypt/Decrypt string VB…

Twitter