HTML Help

Go Back   HTML Help Central > Site Building Central > Javascript / DHTML

Javascript / DHTML This is the place to ask questions about JavaScript and DHTML.

Register Now for FREE!
Join HTML Help Central. To sign up for your FREE account INSTANTLY fill out the form below!

Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
 
Image Verification
Please enter the six letters or digits that appear in the image opposite.

  I agree to forum rules 

» Online Users: 54
0 members and 54 guests
No Members online
» HHC Sponsors
Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2006, 03:35 AM
samliew's Avatar
samliew samliew is offline
HHC Moderator
 
Join Date: Mar 2005
Location: Singapore
Posts: 1,719
Post JavaScript No-Right Click

For the many people who come to our forum asking for a no-right click script to deter your website from leechers, here is the best one that is cross-browser compatible: (Copy and paste this between the <head> </head> of your page)
Code:
<script type="text/javascript"><!--
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
//--></script>
However, I would like to point out that there is not a single script in the world that can really stop people from downloading stuff off the website. Yup, there is always a way to save pages AND the contents.

Quote:
"This script is *NOT* fool-proof. People can disable JavaScript support in their browser, use a browser which doesn't support JavaScript, or use a browser to link directly to the image that you want to protect. Also the pages and images are normally stored in the user's browser cache (for viewing later whilst offline) - with a little bit of work, the thief could find your image in their cache. It also doesn't stop users accessing the source of your page from the toolbar menus (View | Page Source). You could attempt to load your page into a window without toolbars - but again this isn't fool-proof. They can access the page directly, with toolbars, instead of opening it without them as you intended. There is a tool for Microsoft Internet Explorer 5 that will encrypt JScript code - but this is only supported by Microsoft Internet Explorer 5 - and will not allow the scripts to run on any other browser.

If you require to protect your images and or your scripts then don't use it and don't put your images/scripts on the net. If your livelihood relies on people not copying your images - then add a water mark or "sample" stamp to your images."
(javascript.internet.com)
Besides, disabling right-click may render your site inaccessible to left-handed people:
Quote:
Originally posted by starla
In addition to being completely worthless as a means of security, disabling right-click also makes it impossible for many people to use your site at all. Some browsers use the right mouse button as a means of accessing your information. Without it, your page may be rendered completely inaccessable to many users. Left handed people sometimes reverse the function of their mouse buttons so that the right button is used to click links. On a page where the author has attempted to interfere with right clicks, those users will not be able to navigate.
Below is a list of currently known ways to deter people, and how to bypass them.

MASTER LIST OF 'SECURITY' FEATURES
Methods to protect web page code, and the methods to bypass them:

1) No right-click: a) Use the menu [View]-[Source] b) Use a browser that doesn't support that script like mozilla c) Use the context menu button on your keyboard (some PC's doesn't have this) d) Keep the mouse down while clearing the error box with Enter. e) Drag the image from the page to your desktop, or a folder in Windows Explorer. It doesn't work on images that are links, though. f) Use the "save pic" button Internet Explorer floats over an image. g) Raid Internet Explorer's cache for the pic. h) Turn off JavaScript in your browser. i) Use a Download Manager like GetBot. j) Press Shift-F10 in IE for right-click simulation. k) Run the following Javascript in the address bar while viewing the page:
javascript:void(document.onmousedown=null); void(document.oncontextmenu=null);

2) Open pages in a new window without the menu, standard buttons, address bar, status bar, etc. with no right-click script : a) Press [F11] in IE to change to full screen, then you can enable the address bar. Copy the link and paste it into a page, creating a direct link, open it and right click on each link [Save Target As...] b) Press Shift-F10 in IE for right-click simulation

3) Frames with no right-click, no select, no context menu? E.g.: <body onmouseover="window.status=' ';return true;" oncontextmenu="return false" ondragstart="return false" onselectstart="return false"> : a) Use the menu to view the frame source, and save the individual pages' links, then paste it into a page, creating a direct link, open it and right click on each link [Save Target As...]"


Elin, one of our ex-supermods, found an article on the internet explaining why the no-right click script is really useless:
Quote:
Originally Posted by elin
Just an interesting piece of advice. Follow this link, http://webhome.idirect.com/~bowers/copy/copy1.htm
andersgrim, one of our members, found an article on the internet on anticircumvention:
Quote:
In order to control the distribution and use of their works, copyright owners are increasingly embedding access (keep you from accessing the work) and copy (control what you do with the work) protection schemes in their digital works. Under section 1201 of the Digital Millennium Copyright Act (DMCA), the circumvention of these access mechanisms is illegal, with only a few narrow statutory exemptions. The DMCA also prohibits the distribution of programs that can be used to circumvent both copy control and access control technologies.
(http://www.chillingeffects.org/anticircumvention)

Last edited by samliew; 07-04-2006 at 04:45 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginners Javascript Tutorial derfleurer Tutorials, Tips & Tricks 2 11-28-2008 07:09 PM
no right click javascript!! ali Javascript / DHTML 4 06-14-2006 09:16 PM
Changable Link Based on Left Mouse Click or Right Mouse Click Mark Moss Javascript / DHTML 1 11-18-2002 08:21 PM
AAAARRRRGGG!!! - Wierd JavaScript problem!!! xangelusx Javascript / DHTML 4 06-14-2002 08:52 AM
Javascript Menu Template Problem. UseTheMan Javascript / DHTML 1 02-19-2002 06:30 PM

Powered by vBadvanced CMPS v3.2.0
All times are GMT -4. The time now is 08:47 AM.