有没有办法跟踪用户是否打印网页

有没有办法跟踪用户是否打印网页

本文介绍了有没有办法跟踪用户是否打印网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法跟踪用户是否打印了网页?

Is there a way to track if a user prints a web page?

谢谢,格雷厄姆

推荐答案

@Tahir Akhtar 有了使用打印样式表的想法.根据评论,这是行不通的,因为无论浏览器当前是否处于打印视图中,总是 fetched 样式表.

@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属性的选择,background-image被淘汰了,因为它们通常不被浏览器渲染.我的想法是 list-style-imagecursor.

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.

我认为 list-style-image 放在绝对定位的透明

    上可能会在不改变任何视觉效果的情况下做到这一点(我不敢将页面外的元素,因为可能的浏览器优化将其删除).对该资源的每次访问应该来自打印页面或打印预览.

    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.

    这篇关于有没有办法跟踪用户是否打印网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 11:49