Tuesday, 11 June 2013

Print preview using javascript

<script type="text/javascript">
function displayMessage(printContent) {
var inf = printContent;
win = window.open("print.htm", 'popup');
win.document.write(inf);
win.document.close(); // new line
}
</script>
<a href="javascript:void(0);" onclick="displayMessage(printarea.innerHTML)">
<a href="javascript:void(0);" onclick="displayMessage(printarea.innerHTML)">
Print Preview</a>
<div id="printarea"></div>
<div id="printarea">print the text</div>

1 comment: