How to print another page from the current page?

I need to print another page from the current page to better describe my problem. I need to put the print button on one page, but you need to print another page, you also need to send the value to the second page that needs to be printed. If someone can help me, I will be very grateful

+4
source share
4 answers

Follow the link to the page you want to print, with some information in the query string. Then put javascript in the onLoad event for the body indicating the page to print .

+5
source

Just put the printable page in an invisible iframe:

<iframe src="to_print.html" name="frame1"></iframe> <input type="button" onclick="frames['frame1'].print()" value="print!"> 
+3
source

You can load the page to print into a (possibly hidden) iframe, and then call the window.print function on that frame. Using jquery, it will be something like this (not verified):

 $('#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(); } ); }); 
+2
source

On top of my head, I could do the following:

  • Get a print button to send or POST / GET with details on the page you want to print.
  • Upload this data to the page.
  • Ask JavaScript to fire the print event after loading the page you want to print.
  • Send the user to the original page.
0
source

All Articles