View Full Version : Disabling right click
tiff2tiff
08-10-2006, 06:56 AM
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.
codeexploiter
08-10-2006, 09:55 AM
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
jr_yeo
08-12-2006, 02:35 PM
http://www.dynamicdrive.com/dynamicindex9/imagebar.htm
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.