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

KeyCode
backspace8
tab9
enter13
shift16
ctrl17
alt18
pause/break19
caps lock20
escape27
page up33
page down34
end35
home36
left arrow37
up arrow38
right arrow39
down arrow40
insert45
delete46
048
149
250
351
452
553
654
755
856
957
a65
b66
c67
d68
KeyCode
e69
f70
g71
h72
i73
j74
k75
l76
m77
n78
o79
p80
q81
r82
s83
t84
u85
v86
w87
x88
y89
z90
left window key91
right window key92
select key93
numpad 096
numpad 197
numpad 298
numpad 399
numpad 4100
numpad 5101
numpad 6102
numpad 7103
KeyCode
numpad 8104
numpad 9105
multiply106
add107
subtract109
decimal point110
divide111
f1112
f2113
f3114
f4115
f5116
f6117
f7118
f8119
f9120
f10121
f11122
f12123
num lock144
scroll lock145
semi-colon186
equal sign187
comma188
dash189
period190
forward slash191
grave accent192
open bracket219
back slash220
close braket221
single quote222

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 Comment