1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Please donate today & help us with our growing server costs or buy premium for access to our premium products
    Dismiss Notice

Free Disable right click for guests on your forum

Discussion in 'Xenforo Template Mods & Extras' started by HAWK, Mar 22, 2016.

  1. HAWK

    HAWK Administrator Staff Member ADMIN

    Likes Received:
    593
    Trophy Points:
    113
    Gender:
    Male
    This script taken from dynamic drive will disable the right click on your forum for guests. As to offer some protection to your materials being stolen from your forum.

    Note: This will prevent them only for the right click and copy/paste directly.

    Anyway, at the page_container_js_head template, after or before all the code in there, add the following code:
    Code:
    <xen:if is="!{$visitor.user_id}">
    <script type="text/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="Right click is disabled for guests!";
    
    ///////////////////////////////////
    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>
    </xen:if>
    To change the error message that will appear to guests when right clicking at your forum, change this part:

    Code:
    var message="Right click is disabled for guests!";
    to:

    Code:
    var message="Your custom message here";
     

Share This Page