Reputation:
i need to print a different page from the current page , that is to describe my problem more precisely .. i need to put the print button in one page but need to print a different page , also need to send a value to the second page which is to be printed. If somebody could help me will be very much thankfull
Upvotes: 4
Views: 9810
Reputation: 4175
Just put the page to print into an invisible iframe:
<iframe src="to_print.html" name="frame1"></iframe>
<input type="button" onclick="frames['frame1'].print()" value="print!">
Upvotes: 3
Reputation: 12450
You could load the page to be printed into an (possibly hidden) iframe and then call the window.print function on that frame. Using jquery it would be something like this (not tested):
$('#printButton').click(function(evt) {
evt.preventDefault();
$('body').append('<iframe src="document_to_be_printed.php?param=value" id="printIFrame" name="printIFrame"></iframe>');
$('#printIFrame').bind('load',
function() {
window.frames['printIFrame'].focus();
window.frames['printIFrame'].print();
}
);
});
Upvotes: 2
Reputation: 6290
Off the top of my head I could do as follows:
Upvotes: 0
Reputation: 19636
Have the link go the the page you need printing with some information in the query string. Then place javascript in the onLoad event for the body instructing the page to print.
Upvotes: 5