[thelist] javascript to disable right click of images

Richard Morris thelist at web-designers.co.uk
Wed Aug 25 07:00:01 CDT 2004


This seems to work OK, except that IE in XP SP2 blocks it now...

Shove it in the headers.

<!--
var sorry="Sorry, you do not have access to this feature."

isNN = document.layers ? 1 : 0; 

function noContext(){return false;}

function noContextKey(e) {
    if(isNN){
        if (e.keyCode == 96){ return (false);}
    } else {
        if (event.keyCode == 96){ return (false);}
    }
}

function noClick(e){
    if(isNN){
        if(e.which > 1) {alert(sorry); return false;}
    } else { 
        if(event.button > 1){alert(sorry); return false;}
    }
}

if(isNN){ 
    document.captureEvents(Event.MOUSEDOWN);
}

document.oncontextmenu = noContext;
document.onkeypress    = noContextKey;
document.onmousedown   = noClick;
document.onmouseup     = noClick;

// -->
</script>

Richard
 
> -----Original Message-----
> I need a javascript that will disable right clicking and disable the 
> downloading of images.



More information about the thelist mailing list