MrAdam Posted August 7, 2006 Share Posted August 7, 2006 I've made a simple javascript to show a menu when the user right clicks. iv made the first simple bit, and the menu appears in the right place -- but the regular right click context menu appears. Is there anyway to prevent this? <html><head><script type="text/javascript">function showRightButtonBox(event) { if (event.button==2) { var x=event.clientX; var y=event.clientY; var box=document.getElementById("rightButtonBox"); box.style.visibility='visible'; box.style.top=y; box.style.left=x; }}</script></head><body onmousedown="showRightButtonBox(event)"><div id="rightButtonBox" style="position:absolute;top:0px;left:0px;width:200px;height:200px;visibility:hidden;"> link1<br />link2<br />link3</div></body></html> -Thanks Link to comment Share on other sites More sharing options...
tyler Posted August 7, 2006 Share Posted August 7, 2006 I also need a stop right click menu....is there one to put on all your webpages.. Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted August 7, 2006 Share Posted August 7, 2006 MrAdam, I will get to you later...xlx_drag00n_xlx, you shouldn't disable right hand click... people need it! Why do you want to? Is it you don't want people STEELING your website code... because that will not help, it only annoys true visitors!I have "Bookmark This Page" in my right hand click, so I guess I will not bookmark your site... Learning, PHP | Things I know well, HTML, Javascript, and CSS |sounds like you already know Javascript so it shouldn't have a problem write it up quickly.Now, this code I'm going to show you this code that will do the trick but it's hard and complex!!<!-- <body> this is html... and the starting body tag --><!-- oncontextmenu means the righthand click menu --><!-- return false means don't do that --><body oncontextmenu="return false"> Link to comment Share on other sites More sharing options...
tyler Posted August 7, 2006 Share Posted August 7, 2006 No its not that I want them stealing my codes...I dont want them stealing my images, incase they copy my site as in the past.... Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted August 7, 2006 Share Posted August 7, 2006 Well I can click Ctrl + U to view any source and steel any image...I can also use the cache on my search engine to access your source... it doesn't even render any of the DHTML so that code doesn't even get used. Link to comment Share on other sites More sharing options...
tyler Posted August 7, 2006 Share Posted August 7, 2006 I still whant to disable right click :| Link to comment Share on other sites More sharing options...
MrAdam Posted August 7, 2006 Author Share Posted August 7, 2006 im currently trying to make a highly customised webpage, interactive as possible! showcase of what i can do basically. right hand click events were new to me, but that code yo gave me before dcole.ath.cx "<body oncontextmenu="return false">" does the job, thanks alot! But, cud you just explain it a little?-Thanks Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted August 7, 2006 Share Posted August 7, 2006 I don't think I can explain it more, the explaining was like 3 times longer than the code it's self... With the Search engine script I made my comments that explained what I though were like:// stuffI wonder what I ment by that?!?!?!I explain it so people new to html and JS would get it... alot of people ask about how to disable right hand click Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 7, 2006 Share Posted August 7, 2006 I suggest don't go into disabling the context menu, or do support an alternate so users won't go into enabling it again.If you want a prototype script for replacing the default contextmenu, do have a look in my topic "Custom Object" in this forum. Link to comment Share on other sites More sharing options...
Moridin Posted August 7, 2006 Share Posted August 7, 2006 Another way is to simply disable javascript in your browser and anyone can steel everything they want.Sure, it might be an effective way to prevent 12-year-olds, but it is really irritating to block it. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 7, 2006 Share Posted August 7, 2006 Just to sum up what has been said...simply...don't bother.Because every method you can try and use is client side code that means the user can read the code and figure out how to get by it or just simply disable javascript.Not only is it annoying it most often "challenges" the users you really need to protect from to push ahrder and get past your code.I know there are times you really want to prevent people from taking your work but there is no way to 100% secure it and it ends up annoying your users who just want to easily navigate your site. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 7, 2006 Share Posted August 7, 2006 This has been a discussion for ages. Disable this, disable that. Nothing can be disabled with javascript just as aspnetguy says.What we CAN do, is just replace the context menu with something more usefull. Unfortunately, also such a thing can be get by. However, if you support for various nice things to be used on your site, it may prevent the user looking how to turn the replacement off. :)With the link in my above post, I am discussing a creation of mine. It is an actual replacement of the contextmenu, but it is not fully ready yet. Maybe someone like to help me? Link to comment Share on other sites More sharing options...
Guest damian Posted August 12, 2006 Share Posted August 12, 2006 No its not that I want them stealing my codes...I dont want them stealing my images, incase they copy my site as in the past....Whilst it doesn't prevent theft of images for all the reasons given in this post, a way that works for me to discourage most theft, particularly from casual users, is simply to use something like onmouseover to change the image src to a low-res version of the image with 'copyright' or some other text on it.Plus it doesn't get inthe way of bona fide viewers. Link to comment Share on other sites More sharing options...
Chandra.Vedantham@gmail.com Posted August 14, 2006 Share Posted August 14, 2006 Hi,If somone wants to handle/disable right click doesn't always mean that is will be used to restrict the users from downloading the images or javscript source. Moreover it cannot be acheived in simple means.There could some instanes where the designer wants to incorporate a Windows style browsing (I have no experience with other UI based OS ) as in the Explorer View etc. In Such cases you can use the OnContextMenu event handler which is raised when a User right clicks on an element. It is equivalent to the OnClick event of the HTML DOM with only exception that the former is the result of the Right Click and the later is the result of the left click. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 14, 2006 Share Posted August 14, 2006 Actually for the onclick it doesn't matter which mousebutton was used. Just simply the onmousedown and onmouseup together without an onmousemore in between.As I said before, it is never a good thing to disable anything and not presenting a good alternative. With stress on "good". "Anti Right Click" scripts are never a good thing. At least less than like "Contextmenu override" or even "Contextmenu replacement" (are those the same? )People who are disabled to do something with their mouse or browser, often keep on looking for an alternate or to enable it again. However, if they get an alternative form the website, they might remain satisfied and would not look in to disabling the disablement. Link to comment Share on other sites More sharing options...
SFB Posted August 14, 2006 Share Posted August 14, 2006 if you really dont want the user to take your code you can use flash to make your website. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now