I have a website where the users can login and use the contents of the site. I want to disable the print screen so that the users cannot store or download the content from my website. Can anyone help me with disabling the print screen option using php?
Asked
Active
Viewed 4,299 times
0
-
Only way possible, put the following at the top of your file: ` – Alexander O'Mara Dec 24 '15 at 05:22
-
PHP runs on the server. By the time the browser displays the page, it is out of the loop. If you want to do something like this, you need to use Javascript or CSS. But the user can easily override it, since it's client-side. – Barmar Dec 24 '15 at 05:22
2 Answers
0
If you mean the print screen key of the user's keyboard, I'm sorry that is an interaction between your user and their browser. It has nothing to do with PHP.
If something on your site is truly private, don't put it online, that is the safest option.

ben3000
- 4,629
- 6
- 24
- 43
0
You can't disable print screen using php. But you can use javascript to do the same. Try the following code:
<html>
<head>
<script language="JavaScript">
function clp_clear() {
var content=window.clipboardData.getData("Text");
if (content==null) {
window.clipboardData.clearData();
}
setTimeout("clp_clear();",1000);
}
</script>
</head>
<body onload='clp_clear()'>
</body>
</html>

Manikiran
- 2,618
- 1
- 23
- 39
-
Even if that code worked (it won't in any sane browser) this is basically worthless. What about tools that take a screenshot without the clipboard? Like the shortcut in OS X? – Alexander O'Mara Dec 24 '15 at 05:28
-
@AlexanderO'Mara It is still one of the solution rather than your "technologically impossible" statements. – Manikiran Dec 24 '15 at 11:23
-
It's technologically impossible to truly prevent the capture anything you send to them. All this is is a cheap trick that doesn't even work in modern browsers. Does this even work in IE, which is the only browser with this API? I'm pretty sure even old IE did not allow clipboard access outside a user event (it would be a gaping security issue). In modern browsers all it will do is add an error to the console every second. – Alexander O'Mara Dec 24 '15 at 18:19