有没有一种方法,如果用户打印网页追踪? [英] Is there a way to track if a user prints a web page?
问题描述
有没有一种方式,如果用户打印网页追踪?
Is there a way to track if a user prints a web page?
谢谢,
格雷厄姆
Thanks, Graham
推荐答案
@Tahir阿赫塔尔必须使用打印样式表的想法。根据该意见,这并不工作,因为样式表始终是牵强,无论浏览器是否目前在打印预览或没有。
@Tahir Akhtar had the idea of using a print stylesheet. According to the comments, that doesn't work because the stylesheet is always fetched , regardless of whether the browser currently is in print view or not.
如何采取这一进一步:使用打印样式表,并定义它的风格,使得当它呈现的浏览器中获取一定的资源。资源会返回一个透明的形象。
How about taking this further: Use a print stylesheet and define a style in it that makes the browser fetch a certain resource when it's rendered. The resource would return a transparent image.
对于CSS属性的选择,背景图片
是的,因为它们通常不会在浏览器呈现。我以为会是一个列表样式图片
或光标
。
As for the choice of CSS property, background-image
is out, because they are usually not rendered by the browser. My thought would be a list-style-image
or a cursor
.
我觉得列表样式图片
上的绝对位置,透明< UL>
可能做的伎俩在视觉上没有任何改变(我不敢元素位置的页面,因为可能的浏览器优化的切割它拿走外)。该资源的每次访问的应的来自打印一页,或打印preVIEW。
I think list-style-image
on an absolutely positioned, transparent <ul>
might do the trick without visually altering anything (I would not dare to position the element outside the page because of possible browser optimizations cutting it away). Every access to that resource should come from printing a page, or a print preview.
我现在不能测试它,也许以后。如果有人尝试它,我很想听听它是否工作。
I can't test it right now, maybe later. If anybody tries it, I'd be interested to hear whether it works.
这篇关于有没有一种方法,如果用户打印网页追踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!