Protect / Secure your Website Content using jQuery

Now a days website owners want to protect their content from copiers. In order to avoid Plagiarism, it is very necessary to make sure the Content, Source and Images from their site is not copied.

I wrote a simple jQuery code that will protect your content from copying text, dragging images, viewing source, & disables the link which having image paths.

Protect Website Content with jQuery
Protect Website Content with jQuery

jQuery Code

function secure() {
document.onkeypress = function (e) {
e = e || window.event;
if (e.keyCode === 123) {
return false
}
};
document.onmousedown = function (e) {
e = e || window.event;
if (e.keyCode === 123) {
return false
}
};
document.onkeydown = function (e) {
e = e || window.event;
if (e.keyCode === 123) {
return false
}
};
document.oncontextmenu = t;
document.onmouseup = t;
var n = false;
var r = false;
var i = false;
window.onkeyup = function (e) {
if (e.which === 17) n = false
};
window.onkeydown = function (e) {
if (e.which === 17) n = true;
if ((e.which === 85 || e.which === 65 || e.which === 88 || e.which === 67 || e.which === 86 || e.which === 83) && n === true) {
return false
}
};
window.onkeyup = function (e) {
if (e.which === 93 || e.which === 91 || e.which === 224) i = false
};
window.onkeydown = function (e) {
if (e.which === 17 || e.which === 93 || e.which === 91 || e.which === 224) i = true;
if ((e.which === 85 || e.which === 65 || e.which === 88 || e.which === 67 || e.which === 86 || e.which === 83) && i === true) {
return false
}
};
document.ondragstart = t;
e("a").each(function (t, n) {
var r = n.href;
if (/\.(jpg|png|gif)$/.test(r)) {
e(this).prop("href", "#")
}
})
}

You can customize the script based on your requirements. Here is the complete keycodes

Key Code
backspace 8
tab 9
enter 13
shift 16
ctrl 17
alt 18
pause/break 19
caps lock 20
escape 27
page up 33
page down 34
end 35
home 36
left arrow 37
up arrow 38
right arrow 39
down arrow 40
insert 45
delete 46
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
a 65
b 66
c 67
d 68
Key Code
e 69
f 70
g 71
h 72
i 73
j 74
k 75
l 76
m 77
n 78
o 79
p 80
q 81
r 82
s 83
t 84
u 85
v 86
w 87
x 88
y 89
z 90
left window key 91
right window key 92
select key 93
numpad 0 96
numpad 1 97
numpad 2 98
numpad 3 99
numpad 4 100
numpad 5 101
numpad 6 102
numpad 7 103
Key Code
numpad 8 104
numpad 9 105
multiply 106
add 107
subtract 109
decimal point 110
divide 111
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
num lock 144
scroll lock 145
semi-colon 186
equal sign 187
comma 188
dash 189
period 190
forward slash 191
grave accent 192
open bracket 219
back slash 220
close braket 221
single quote 222

View Live Demo & Download

Please don’t forget to share and subscribe to latest updates of the blog.

Thanks!

You May Also Like

Never Miss Any Web Tutorials, Guides, Tips and Free eBooks

Join Our Community Of 50,000+ Web Lovers and get a weekly newsletter in your inbox

 

I hate spam too. Unsubscribe at any time.

10 thoughts on “Protect / Secure your Website Content using jQuery”

  1. hai i’m trying to download this file but its not download and i have already subscribed it. when i entered my email id (sbmanure@gmail.com) it showing Email does not exist in our database. pls send me this file directly to email id

    Reply
  2. Not so secure! All I had to do was view the source of the page, and I downloaded secure.js, the page code, and any content I wanted. However, it will secure against normal users.

    Reply

Leave a Reply to sadashiv Cancel reply