PDA

View Full Version : Right Click



dt9447
05-11-2007, 09:00 PM
A relative novice learning very basic html and scripts myself as I go along, I wonder if anyone can point me in the direction of a code....
I have a javascript on my webpage to disable right click. I wonder is it possible to play a .wav of my choice rather than the default windows sound?
I did try to contact the writer of the code whose details I have left in the code on my site but he doesn't seem to respond.

Could I edit?

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Uh Uh";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>

Anyone help?

Thanks Dan

thetestingsite
05-11-2007, 09:16 PM
There is nothing in the code that triggers any sound other than that of the default Windows "alert" chime. This cannot be changed (unless changed by the user on their computer). If you didn't want the alert box to show up, you could simply take out all the parts in red in the below code:



<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Uh Uh";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>


Hope this helps.

dt9447
05-11-2007, 09:24 PM
Understood....love tinkering...and one can learn something new every day thanks to forums.

Thank you mate

djr33
05-11-2007, 10:50 PM
Note that the script is just doing exactly what you see, for those users who do have javascript enabled and don't know how to get around it.
For a user who intends to steal something, it is very easy for them to do so.
In short, the script is basically worthless. Search for similar discussions if you want more info.