Results 1 to 3 of 3

Thread: Disabling right click

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Disabling right click

    Hey guys, anyone can help me on this?

    Ok, I've got the script for disabling right click on images. But when I left click on my image, the image will appear in a new pop up window and I can save it from there. Any idea how to solve this?

    I'm an idiot at these scripts. Forgive me.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Thumbs up

    Hi

    Even if you disable the right mouse click and save as option on image from being saved, one user can save the web page completely into their machine as a result of this they'll be able to get the images, text content, client-side script, etc used in the page.

    For your query as you haven't mentioned the code used here i am assuming that you are using Javascript code for disabling the right mouse click on the images. Please have a look at the following code

    <script>
    function buttonClick()
    {
    if (event.button == 2)
    {
    alert('You can not Save the Image using Right-Click');
    return false;
    }
    }
    </script>
    <img src="banner.gif" onMouseDown="buttonClick();">

    The above one is a very very basic Javascript for disabling the right mouse button click. This is just to give you an idea about how this things works.

    If you look at the <img> tag I've invoked my function buttonClick at onMouseDown event. so whenever the user presses his/her mouse button -left/right it will invoke this function. If you are pressing left mouse button event.button will give a value of 1 and if the button is right then it will return a value 2.

    So if your mouse button down event give a value of 2 it trigger the action that we want to do whenever the user press right-mouse button and it shows an alert window.

    You can call the function on any image's onMouseDown event which you want to restrict from saving using the right-click button

    Hope this is what you looks for

    Regards

    Code Exploiter

  3. #3
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please don't mind me. I am just posting a lot of nonsense.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •