Урока има за цел да Ви покаже по какъв начин можете да забраните
копирането на съдържанието в документа.
1. Добавете следния код в боди тага
CODE1
2
3
| oncontextmenu="return false"
боди тага трябва да изглеежда така
<body oncontextmenu="return false"> |
2. Добавете следния javascript в head тага
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <script language="JavaScript1.2">
function disabletext(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=disabletext
document.onclick=reEnable
}
function checkkey(e)
{
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
var key;
if(ie4)
key=window.event.keyCode;
else
key=e.which;
alert(key);
if(key == 17)
{
event.returnValue = false;
return false;
}
}
document.addEventListener("keydown", checkkey, false);
document.addEventListener("keypress", checkkey, false);
document.onkeypress =checkkey;
window.onkeypress =checkkey;
if (document.layers || (document.getElementById && !document.all)) {
document.captureEvents(Event.KEYPRESS);
document.captureEvents(Event.MOUSEDOWN);
}
</script> |
Готово , вече имате защитено от копиране съдържание