943,191 Members | Top Members by Rank

Ad:
Mar 28th, 2006
0

wanna help..how to avoid default context menu

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pavankishore is offline Offline
4 posts
since Mar 2006
Mar 28th, 2006
0

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

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.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Mar 28th, 2006
0

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

Wait... I know IE provides an "oncontextmenu" event handler. I'm not sure about FireFox.

You could code that in the body, as so:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <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.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Mar 29th, 2006
0

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

Quote 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:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pavankishore is offline Offline
4 posts
since Mar 2006
Mar 29th, 2006
0

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

I suppose the best option would be to add to the standard context menu, is that an option tgreer?
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Mar 29th, 2006
0

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

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
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Mar 29th, 2006
0

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

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Please help, been a few years.
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Dynamically write selectedIndex to a <dl> element





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC