Get Latest Tweaks via Facebook, Twitter, Google+ & FeedBurner
    Subscribe:
    Subscribe Twitter Facebook

    Sunday, November 4, 2012

    Disable Right Click Context-Menu On Images

    SOCIALIZE IT →



    If you don't want that some one copying your images easily without your permission then this is the script to prevent users doing that. It disabled right click Context-Menu On images so no one can use image save option to copy or save your images.


    1. Disabling Right Click on all Images


    With Alert Box :

    <script type="text/javascript">
    //<![CDATA[
        function nocontext(e) {
            var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
            if (clickedTag == "IMG") {
                alert(alertMsg);
                return false;
            }
        }
        var alertMsg = "Image context menu is disabled";
        document.oncontextmenu = nocontext;
    //]]>
    </script>
    

    Without Alert Box:

    <script type='text/javascript'>
    //<![CDATA[
        function nocontext(e) {
            var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
            if (clickedTag == "IMG") {
                
                return false;
            }
        }   
        document.oncontextmenu = nocontext;
    //]]>
    </script>
    

    2.Disabling Right Click on Specific Image


    Add This Code within <img> Tag

    oncontextmenu='alert("Image context menu is disabled");return false;'
    

    Example:

    <img oncontextmenu='alert("Image context menu is disabled");return false;' src="http://4.bp.blogspot.com/-UzwQrb-UgQY/UJaD0AG7jMI/AAAAAAAAIak/fdcIYpOHXAA/s1600/right-click-disable-on-images.jpg" />
    

    Right click on images will be disabled to users, first checkout your self.


    0 comments:

    Post a Comment