Click here to Skip to main content
15,886,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How to write a print fucntionality in javascript and html. when i click on the Print button; it has to print the map on the browser. this is related to GIS website.
Posted

1 solution

Please see:
http://www.htmlgoodies.com/beyond/javascript/article.php/3471121/Print-a-Web-Page-Using-JavaScript.htm[^],
http://www.javascripter.net/faq/printing.htm[^],
http://www.tutorialspoint.com/javascript/javascript_page_printing.htm[^].

You can find a lot more: http://bit.ly/102tfPX[^].

I would give you some advice. You can trust your user more: this is the one who knows when to print and how. However, you need to provide a "printable version" of the data presented on the page, which does not have to be the page itself. A print on the page and a Web page are very different kinds of media. For example, it's totally pointless to print check boxes, text input controls, as the user's click on paper won't work anyway :-). But you need to print corresponding data.

One of the nice ways for presenting the "printable version" in an integral and transparent way, is CSS @media feature. You can provide the same content, but use different CSS rules to hide are re-arrange some elements depending on the media. Please see:
http://www.w3schools.com/css/css_mediatypes.asp[^],
http://www.w3.org/TR/CSS2/media.html[^],
https://developer.mozilla.org/en-US/docs/CSS/@media[^].

Good luck,
—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 17-Jan-13 16:24pm    
Good points :-D
Sergey Alexandrovich Kryukov 17-Jan-13 16:41pm    
Thank you, Espen.
—SA
Manas Bhardwaj 17-Jan-13 16:55pm    
Good answer +5!
Sergey Alexandrovich Kryukov 17-Jan-13 16:57pm    
Thank you, Manas.
—SA
Adam R Harris 17-Jan-13 17:47pm    
Good answer, my 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900