Java script : no right click

Discussion in 'Skinning, Design and Graphics' started by southernlady, Jan 31, 2006.

  1. southernlady

    southernlady Regular Member

    Joined:
    Apr 30, 2005
    Messages:
    276
    Likes Received:
    3
    Here is one of my text files from my "toolbox" i thought i would share... let me know if there is more interest for post like this... any request? needs? wants?

    i have not removed the credit for the scripts... however i have taken the liberty of putting them all together and adding my own comments to them... as displayed these are not in original format however the authors still get credit for the work.

    Code:
    **********************************************************************
    DISABLE RIGHT CLICK SCRIPT (ENTIRE DOCUMENT)
    Simply add the following code to the <BODY> section of your web page
    **********************************************************************
    <script language=JavaScript>
    <!--
    
    //Disable right mouse click Script
    //By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
    //For full source code, visit [url]http://www.dynamicdrive.com[/url]
    
    var message=&quot;Function Disabled!&quot;;
    
    ///////////////////////////////////
    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(&quot;alert(message);return false&quot;)
    
    // --> 
    </script>
    
    **********************************************************************
    
    
    
    
    
    
    **********************************************************************
    DISABLE RIGHT CLICK SCRIPT (ON IMAGES ONLY)
    Simply add the following code to the END of your page, right above the </body> tag:
    **********************************************************************
    <script language=&quot;JavaScript1.2&quot;>
    
    /*
    Disable right click script II (on images)- By Dynamicdrive.com
    For full source, Terms of service, and 100s DTHML scripts
    Visit [url]http://www.dynamicdrive.com[/url]
    */
    
    var clickmessage=&quot;Right click disabled on images!&quot;
    
    function disableclick(e) {
    if (document.all) {
    if (event.button==2||event.button==3) {
    if (event.srcElement.tagName==&quot;IMG&quot;){
    alert(clickmessage);
    return false;
    }
    }
    }
    else if (document.layers) {
    if (e.which == 3) {
    alert(clickmessage);
    return false;
    }
    }
    else if (document.getElementById){
    if (e.which==3&&e.target.tagName==&quot;IMG&quot;){
    alert(clickmessage)
    return false
    }
    }
    }
    
    function associateimages(){
    for(i=0;i<document.images.length;i++)
    document.images[i].onmousedown=disableclick;
    }
    
    if (document.all)
    document.onmousedown=disableclick
    else if (document.getElementById)
    document.onmouseup=disableclick
    else if (document.layers)
    associateimages()
    </script>
    
    **********************************************************************
    
    
    
    
    
    **********************************************************************
    NO NOTIFICATION BOX
    **********************************************************************
    
    <script language=JavaScript>
    <!--
    
    //Disable right click script III- By Renigade (renigade@mediaone.net)
    //For full source code, visit [url]http://www.dynamicdrive.com[/url]
    
    var message=&quot;&quot;;
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if 
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers) 
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    
    document.oncontextmenu=new Function(&quot;return false&quot;)
    // --> 
    </script>
    
    
    
    **********************************************************************
    
    
    **********************************************************************
    There are two ways to disable the Image Toolbar in IE6:
    
    1) Insert the following META tag into the <head> section of your page. Doing so will disable the toolbar for all images on the page:
    
    **********************************************************************
    <META HTTP-EQUIV=&quot;imagetoolbar&quot; CONTENT=&quot;no&quot;>
    **********************************************************************
    
    2) OR, inside the particular image(s) in question, add the one attribute as shown. This affects only the containing image:
    
    **********************************************************************
    <img src=&quot;test.gif&quot; GALLERYIMG=&quot;no&quot;>
    **********************************************************************
    Posted by Ken
     

Share This Page