Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 371
Graham Avatar asked Jan 27 '10 15:01

Graham


People also ask

Can a website tell if you print the page?

A website can know if you take a screenshot of it. Because any website can track the keys you press using code. So they can trigger an event that records when somebody presses the print screen button on a page of their website.

How do I print a Web page using Javascript?

To print a page in JavaScript, use the print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.

How do I print part of a page?

Drag a rectangle around the area you want to print. Choose File > Print. Make sure that the Selected Graphic option is selected in the Print Range area of the Print dialog box. (Optional) To enlarge the selected text or graphic to fit the sheet of paper, choose Fit To Printable Area from the Page Scaling pop-up menu.


1 Answers

@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.

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.

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.

like image 154
Pekka Avatar answered Oct 14 '22 13:10

Pekka