How to block printscreen on a web page?

Asked

Viewed 303 times

0

I know that for Android development there is the command:

getwindow().setflags(windowmanager.layoutparams.flag_secure windowmanager.layoutparams.flag_secure)

Which prevents the printscreen and even recording the screen by some app. I was wondering if you could implement something similar on a website by some modification on DOM or something like that.

1 answer

3


There’s no way.

The HTML, CSS and Javascript of any website are executed in a type of sandbox which the browser creates for each "tab". If the browser itself, as an application, already prevents Javascript, for example, to perform actions that exceed the scope of the tab to which the script is being performed, manipulations involving the operating system are much above the Javascript "permissions loop" run by the websites.

In other words, the restriction level is much higher than Javascript can perform. Screen capture is not an application feature (like the browser), but an operating system feature.

The commando that you mentioned is an API provided by operating system Android for which applications manipulate the screenshot. The browser, as an application, could access this API, but Javascript, which runs within browser does not have "permission" to access it.

It would be a huge security flaw to allow Javascript to access this type of API relatively more low-level of the operating system.

If you’re talking about Node.js or Deno, that’s another story (but that’s not the case).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.