Re:How to prevent screenshots in a web browser
by colanderman on Monday July 14, 2014 @01:02PM
(#8031888)
Well, the website's down, so I can only speculate, but, how is the website to know the screen's refresh rate? If the site assumes, say, 60 Hz, but the rate is actually 72 Hz, you'll see an odd "fading" effect between the two interlace frames at a rate of 12 Hz, which is very noticeable.
EDIT: Ah, I see he uses window.requestAnimationFrame [1] to sync with the frame rate, so this is not a problem.
[1] https://developer.mozilla.org/en-US/docs/Web/API/window.requ...
Re:How to prevent screenshots in a web browser
by mikeash on Monday July 14, 2014 @01:08PM
(#8031931)
It doesn't actually have to know. There's a JavaScript API called requestAnimationFrame which asks the browser to invoke a callback for the next display refresh. Invoke requestAnimationFrame again from that callback, and you'll get a steady stream of callbacks at the display refresh rate, or whatever the browser thinks it is.
Here's the relevant code from the demo:
var work = (function() {
var toggle = false;
return function tester() {
frame1.style.opacity = toggle?.5:1;
frame2.style.opacity = toggle?1:.5;
toggle=!toggle;
requestAnimationFrame(tester);
};
})();
requestAnimationFrame(work);
For this to work perfectly, your monitor refresh rate would need to be at least 2x higher than what your eyes can detect. And why would anyone build hardware with such a fast refresh rate?
It's a cute idea, but in the end it ruins the image for normal uses just like the watermarks do.