ASP Snippets

Categories






Alerts

Free Alerts

Your email will always be
private and will not be shared.




Follow us on twitter.




Zoom In | Zoom Out


Author is awarded Most Valuable Professional award by Microsoft ASP/ASP.Net

Disable Right Click in Browsers

Author:Mudassar Khan

Below is the JavaScript Snippet to disable Right Click in Browsers.


<script type = "text/javascript">

    function mousedown()

    {

       return false;

    }

    function mouseup(e)

    {

        if(e != null && e.type == "mouseup")

        {

            if (e.which==2||e.which==3)

            {

                    return false;

            }

        }

    }

    function contextMenu()

    {

        return false;

    }

   

    if (document.layers)

    {

        document.captureEvents(Event.MOUSEDOWN);

        document.onmousedown=mousedown;       

    }

    else

    {

        document.onmouseup=mouseup;

    }

    document.oncontextmenu=contextMenu;

</script>



This page is also using the above script for Disabling Right Click.



It has been tested for the following Browsers.

1.     Internet Explorer 7

2.     Firefox 3

3.     Google Chrome


You can download the sample source code here

DisableRightClick.zip (1.18 kb)

Posted: Feb 07 2009, 19:23 by Mudassar Khan | Comments (9) RSS comment feed |
Filed under: JavaScript

Views: 2527
Page copy protected against web site content infringement by Copyscape


If you like this article, help us grow by bookmarking this page on any social bookmarking site.
Bookmark and Share





Comments









Community News





Web Hosting SpotLight


Consulting


For consulting and work related queries click here.



Advertise


Advertise with us. For more details click here.


Suggestions


Please provide your valuable suggesstions here.

This Site is hosted on

Lunarpages.com Web Hosting