News for hackers. Stuff that matters.
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);

There are no comments on this comment yet.