在JavaScript中打印功能 [英] Print Functionality in JavaScript
本文介绍了在JavaScript中打印功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在javascript和html中编写打印功能。当我点击打印按钮时;它必须在浏览器上打印地图。这与GIS网站有关。
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.
推荐答案
请参阅:
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 [ ^ ] 。
你可以找到更多: http://bit.ly/102tfPX [ ^ ]。
我会给你一些建议。您可以更信任您的用户:这是知道何时打印以及如何打印的人。但是,您需要提供页面上显示的数据的可打印版本,而不必是页面本身。页面上的打印和网页是非常不同的媒体类型。例如,打印复选框,文本输入控件完全没有意义,因为用户点击纸张无论如何都不会工作:-)。但是你需要打印相应的数据。
CSS @media功能是以完整透明的方式呈现可打印版本的好方法之一。您可以提供相同的内容,但使用不同的CSS规则进行隐藏会根据媒体重新排列某些元素。请参阅:
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 [< a href =https://developer.mozilla.org/en-US/docs/CSS/@mediatarget =_ blanktitle =New Window> ^ ]。
祝你好运,
-SA
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
这篇关于在JavaScript中打印功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文