当前位置: 首页 > 网络学院 > 网页制作基础教程 > WEB设计综合 > 除去打印脚本
Demo: Try to Print this page or Print Preview
演示:尝试打印这个页面或进行打印预览
<style type="text/css" media="print"> |
Put the above script between the <head> </head> tags in your page. It will make your page empty when it is printed. The code is fairly simple to understand.
将上面的脚本程序放置在<head></head>标签之间,这样一来,当选择打印页面时,显示出来的将是空白页面。这个代码非常容易理解。
<style type="text/css" media="print"> |
Here we declare that the following script is a CSS Script and media is print which means it is intended for paged, opaque material and for documents viewed on screen in print preview mode.
在这里,我们声明了下面这段脚本程序是一个CSS脚本程序,媒体类型为“print”(意指页面、实体材料或文档在显示器上将以打印预览的方式显示)。
body |
Sets the body of the page to blank when the page is printed.
当向页面发出打印请求时,将页面本身设置为空白。
Note: This is especially useful when you don't want some of the pages on your website to be printed and only be read online. Of course you can’t protect the content of the page with this script alone, because cut and paste still would print work here. That is another issue which is not discussed here.
注意:如果你只希望访问者读取页面的内容而不允许他们打印,那么你会发现,这个脚本程序是非常有帮助的。当然,你不能仅靠这段脚本程序来保护你的页面内容,因为“剪切”、“粘贴”功能仍然可以发挥作用。关于页面内容的保护问题我们不在这里赘述。