如何使网页发送到打印机的内容与浏览器窗口中的内容不同? [英] How can you make a web page send to the printer something different than what's in the browser window?

查看:24
本文介绍了如何使网页发送到打印机的内容与浏览器窗口中的内容不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 地图曾经在您点击打印"时执行此操作.链接,发送到打印机的内容并不完全是您在屏幕上看到的内容,而是几乎相同信息的不同格式版本.

Google Maps used to do this bit where when you hit the "Print" link, what would be sent to the printer wasn't exactly what you had on the screen, but rather a differently-formatted version of mostly the same information.

他们似乎已经基本上摆脱了这个概念(我猜人们不理解它)并且大多数网站都有印刷版".诸如文章之类的东西.

It appears that they've largely moved away from this concept (I guess people didn't understand it) and most websites have a "print version" of things like articles and so forth.

但是如果你想制作一个打印机友好"的网页页面的版本是发送到打印机的内容,而无需为其制作单独的页面,您会怎么做?

But if you wanted to make a webpage such that a "printer friendly" version of the page is what gets sent to the printer without having to make a separate page for it, how would you do that?

推荐答案

你可以通过创建一个直接针对打印的css样式表和另一个直接针对屏幕的css样式表来实现这个效果.

You can achieve this effect by creating a css stylesheet which is targeted directly to printing, and another targeted directly for the screen.

使用链接标签:

<link rel="stylesheet" type="text/css" href="print.css" media="print, handheld" />
<link rel="stylesheet" type="text/css" href="screen.css" media="screen" />

将您的样式表嵌入到您的文档中.

to embed your stylesheet into your document.

隐藏很容易,只需将您的块样式设置为隐藏在您想要的任何样式表中,它就不会显示.例如:

To hide is easy, just set your block style to hidden in whatever stylesheet you want and it wont be displayed. For example:

.newStyle1 {
    display: none;
}

然后任何设置为 newStyle1 样式的东西都不会显示.

Then anything set to the style of newStyle1 will not be displayed.

这篇关于如何使网页发送到打印机的内容与浏览器窗口中的内容不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆