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.
How to Disable source code and Right click mouse?
812 views Asked by saranguru At
2
There are 2 answers
0
On
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.