User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,868 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,503 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1681 | Replies: 6 | Solved
Reply
Join Date: Mar 2006
Posts: 4
Reputation: pavankishore is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pavankishore pavankishore is offline Offline
Newbie Poster

wanna help..how to avoid default context menu

  #1  
Mar 28th, 2006
Hai group,


im a newbie in HTML,CSS,JAVASCRIPT..
I was involved in dev of a prototype using the above 3...
everything went fine...but the pending requirement is ..
when we right click on a row in table in a prototype, we have coded such that a context menu appears..its working fine..but if we click on empty space in the html prototype, we r getting the default context menu which we dont want...

could any one of u can help me plzzzzzzz
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: wanna help..how to avoid default context menu

  #2  
Mar 28th, 2006
I think you'll have to code to the Event object, which has cross-browser issues. But the Event object is created when any event occurs, and you might be able to tell if a click was a left or a right click and code accordingly. So my first thought would be to research the JavaScript "Event" object.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: wanna help..how to avoid default context menu

  #3  
Mar 28th, 2006
Wait... I know IE provides an "oncontextmenu" event handler. I'm not sure about FireFox.

You could code that in the body, as so:

<body oncontextmenu="return false;">

However, this is where I make my standard plea/warning: users expect that when they right-click, they get a context menu. I, for example, routinely use it to access "back". It's faster than mousing up to the top of the browser. Disabling or co-opting features that users have come to expect violates a basic application design principle, and should be avoided, in my opinion.

So unless you have a very compelling reason for doing this, I would suggest that you leave it alone.
Reply With Quote  
Join Date: Mar 2006
Posts: 4
Reputation: pavankishore is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pavankishore pavankishore is offline Offline
Newbie Poster

Re: wanna help..how to avoid default context menu

  #4  
Mar 29th, 2006
Originally Posted by tgreer
Wait... I know IE provides an "oncontextmenu" event handler. I'm not sure about FireFox.

You could code that in the body, as so:

<body oncontextmenu="return false;">

However, this is where I make my standard plea/warning: users expect that when they right-click, they get a context menu. I, for example, routinely use it to access "back". It's faster than mousing up to the top of the browser. Disabling or co-opting features that users have come to expect violates a basic application design principle, and should be avoided, in my opinion.

So unless you have a very compelling reason for doing this, I would suggest that you leave it alone.
Thanks a lot...that worked fine...
Reply With Quote  
Join Date: Feb 2005
Posts: 354
Reputation: DanceInstructor is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 12
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: wanna help..how to avoid default context menu

  #5  
Mar 29th, 2006
I suppose the best option would be to add to the standard context menu, is that an option tgreer?
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: wanna help..how to avoid default context menu

  #6  
Mar 29th, 2006
We're venturing off into another discussion. I don't know the particulars of the OP's environment or application, but in general, I say "hands off" on anything that is in the User Model. This includes such often-requested items as auto-sizing a window, auto-printing a page, disabling certain script warnings, obscuring or making "View Source" difficult, and replacing or editing the context menu.

This link should be of interest to you in regard to adding to context menu(s):

http://msdn.microsoft.com/workshop/b...ls/context.asp
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: wanna help..how to avoid default context menu

  #7  
Mar 29th, 2006
That's something you have to do internally to your windows machine though (which rocks for me, but not for someone trying to do it through a web page... now if we can find out where that same type of key is for firefox).

If I'm not mistaken, you could use a DIV with some crazy CSS (to hide and show the div) with an absolute positioning, set the oncontextmenu to a function (which shows the div, and returns false for the actual context menu), but the context menu has things that you can't make happen within a page.

but I seriously agree with tgreer, screwing with people's interface is a bad idea.... 9 times out of 10, if a page is messing with things I don't think it should be, I'm gone. I won't stay there. I don't even like pages playing music, or embedding objects (like media player) when I first navigate there. Now, I've done this before (made a page which replaces the context menu), but I made it a choice in preferences, and I made it disabled by default (meaning, in order to use my div menu, they had to consciously go in and turn it on), and beyond that, I made an option in the DIV for "Standard Menu" so when they clicked that, it would load the normal context menu the next time they clicked.

If you feel absolutely drawn to having to affect the users interface, words of wisdom say to make sure that the user can get back to a familar environment with no effort.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC