Hi,
I need some code that disables mouse clicks and right clicks on the html page and another to re-enable the mouse clicks.
Printable View
Hi,
I need some code that disables mouse clicks and right clicks on the html page and another to re-enable the mouse clicks.
http://javascript.internet.com/page-...ght-click.html
In the code, insert your own variable, depending upon whose value the script may or may not execut.e
<script language="JavaScript">
<!--
// No rightclick script.
// Find more great scripts and applets at the JavaFile!
// http://www.javafile.com
// Do not delete this header!
var message="Hey I Took A Long Time On This Site And You Are Not Stealing Any Of My Script!"; // Put your message for the alert box between the quotes.
// Don't edit below!
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// -->
</script>
This script disables right click, i use it a lot on my sites
That only works if you include the message box...there is a way to do it if you don't want a message box, I just need to find it.
This seems to do the trick:Code:<script language ="javascript">
function cancelClick() {
window.event.CancelBubble = true;
window.event.returnValue = false;
}
document.oncontextmenu=cancelClick;
</script>