[RESOLVED] Validate code
I am using this line of code to prevent right-click (and subsequently
It's a standard code, except that the browser warning is suppressed. And it works fine.
<img src="img/myimage.jpg" onMouseDown="if (event.preventDefault) event.preventDefault()" oncontextmenu="return false;" >
Unfortunately, this is not valid coding. So, is there a way to fix it?
Oh, and please no discussions about preventing theft from websites. I know nothing really works, I just want to deter the majority of web users.
Thanks in advance.
Last edited by Pris; 08-08-2011 at
Reason: correction of a very dumb typo
check event object an method .preventDefault()
for Microsoft Interne Explorer see http://msdn.microsoft.com/en-us/library/ms535863.aspx
this check a pointer like if(event.preventDefault!=null)
Thanks twseitex, will look into your solution asap.
Found a jQuery snippet that works nicely:
Note: it comes from
here and I adapted it. The original code disables right-click completely, but I do want visitors to be able to open links in new tabs or copy text. So here you go, disable right-click on images with jQuery.
Users Browsing this Thread
There are currently 1 users browsing this thread.
(0 members and 1 guests)
Tags for this Thread