Print contents using javascript (*.js)

1. Javascript code, put the following code in printContent.js file

function printSelection(node) {

var content = node.innerHTML
var pwin = window.open(”, ‘print_content’, ‘width=500,height=500′);
pwin.document.open();
pwin.document.write(” + content + ”);
pwin.document.close();
pwin.focus();
pwin.print();
pwin.close();
}

2. Calling the javascript function from a *.html page on client click of a control

“printSelection(document.getElementById(‘chartRenderArea’));return false;”

here, chartRenderArea is the id of the div tag.

Advertisement

Leave a Comment

Filed under javascript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s