Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing contents of another page

In the following link

<a href=\"#\" onclick=javascript:print(\"\") style=\"color:blue;\">Print</a>"
<script>
 function print()
 {
      //How to print the contents of another page
 }
like image 948
Hulk Avatar asked Apr 05 '10 11:04

Hulk


People also ask

How do I print the contents of a page?

Printing Simplified Web Pages With Chrome's Inbuilt SettingsWhen you're on the page you want to print, press “Ctrl+P” which will bring up the Print interface.

How do I print just a div?

To print the content of div in JavaScript, first store the content of div in a JavaScript variable and then the print button is clicked. The contents of the HTML div element to be extracted.


1 Answers

If you already have an external page( letterprint.php ), put that page in a hidden iframe and print the content of iframe by using onclick attribute in a button.

<iframe src="letterprint.php" style="display:none;" name="frame"></iframe>

<input type="button" onclick="frames['frame'].print()" value="printletter">
like image 104
151291 Avatar answered Oct 25 '22 13:10

151291