Which script is used in this website ? We cannot View Source code (Ctrl+U) and Right click mouse. I want to add like this script to my site. Could you please provide the script.
Asked
Active
Viewed 802 times
-4
-
1It's still trivial to see the source code and to get the images... Try F12 for example... This is childish... – Denys Séguret Dec 21 '16 at 10:55
-
1http://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page – Krzysztof Kaźmierczak Dec 21 '16 at 11:00
-
always research other answers before asking one yourself – mike510a Dec 21 '16 at 11:07
-
It's futile, not sure why you would want to, what's your use-case? – darryn.ten Dec 21 '16 at 11:35
2 Answers
0
var isCtrl = false;
document.onkeyup=function(e)
{
if(e.which == 17)
isCtrl=false;
}
document.onkeydown=function(e)
{
if(e.which == 17)
isCtrl=true;
if((e.which == 85) || (e.which == 67) && (isCtrl == true))
{
return false;
}
}
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;

Nishant Saini
- 421
- 3
- 13
-
Hi use upper code inside your head section or before closing body tag – Nishant Saini Dec 21 '16 at 11:00
0
That page uses the following code:
document.oncontextmenu = function(e) {
var t = e || window.event;
var n = t.target || t.srcElement;
if (n.nodeName != "A") return false
};
document.ondragstart = function() {
return false
};
function disableSelection(e) {
if (typeof e.onselectstart != "undefined") e.onselectstart = function() {
return false
};
else if (typeof e.style.MozUserSelect != "undefined") e.style.MozUserSelect = "none";
else e.onmousedown = function() {
return false
};
e.style.cursor = "default"
}
window.onload = function() {
disableSelection(document.body)
}
<div style="height: 150; width: 150">
<a href="link1.html">link 1</a>
</div>
By the way, you cannot protect Javascript source code from being stolen or viewed, as the person visiting the page must be able to view the script in order to run it.

Gerard Cuadras
- 1,655
- 1
- 17
- 23

mike510a
- 2,102
- 1
- 11
- 27