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
+5
A:
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.
Sam152
2009-02-24 07:23:09
A:
Off the top of my head I could do as follows:
- Get the print button to send a or POST/GET with the details to the page you want to print.
- Load those details onto the page.
- Have a JavaScript trigger the print event once you load the page you want to print.
- Send the user back to the original page.
Marcel Tjandraatmadja
2009-02-24 07:25:44
actually i dont want to display the whole contents of the page on to the page , so i need to add some more data into the page that i want to print , that is show in the printed document but not on the web page
2009-02-24 07:50:34
+1
A:
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();
}
);
});
kkyy
2009-02-24 07:31:55
+1
A:
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!">
amartynov
2009-02-24 07:32:06
can i pass a value to this page like <iframe src="to_print.html?val='<?=john?>'" name="frame1"></iframe>
2009-02-24 07:42:49
Sure! Moreover, if the pages are within a single domain, you can access the document via frames[name].document property.
amartynov
2009-02-24 07:44:36
thanks amartynov really appreciate the help will try it and ask if any problems appear , thanks again..;)
2009-02-24 07:52:06
hey amartynov having a small problem i did this<iframe style="display:none" src="collection_Report.php?cono=<?=$control_no?>" name="frame1" ></iframe><input type="button" onclick="frames['frame1'].print(<script>frames['frame1'].style.display='block';</script>)" value="print!"> but it doesnt print
2009-02-24 08:17:19
ah, instead of "display:none" you may use something like "position:absolute; top: -10px; width:0; height:0;"
amartynov
2009-02-24 08:38:31