Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML
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 17-Jan-13 8:28am
lisalis197

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 Smile | :) . 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
  Permalink  
v2
Comments
Espen Harlinn at 17-Jan-13 16:24pm
   
Good points :-D
Sergey Alexandrovich Kryukov at 17-Jan-13 16:41pm
   
Thank you, Espen.
—SA
Manas Bhardwaj at 17-Jan-13 16:55pm
   
Good answer +5!
Sergey Alexandrovich Kryukov at 17-Jan-13 16:57pm
   
Thank you, Manas.
—SA
Adam R Harris at 17-Jan-13 17:47pm
   
Good answer, my 5.
Sergey Alexandrovich Kryukov at 17-Jan-13 17:52pm
   
Thank you, Adam.
—SA

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 363
1 OriginalGriff 344
2 George Jonsson 238
3 Shemeemsha RA 148
4 Animesh Datta 130
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100