Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Firefox does not honor right-click over disabled fields
Old 04-14-2006, 01:39 AM Firefox does not honor right-click over disabled fields
Junior Talker

Posts: 3
Trades: 0
Howdy -
Don't have code right in front of me, but here goes. I'm using some slick javascript to override the default right click context menu, and pop up a custom menu whenever a user right-clicks on an html form element because I want to take some user specified action (via the popup menu) on the field's value. This works fine in both Firefox 1+ and IE 6+, which are the target browsers, until I disable the fields, which is the realistic scenario. It still works fine in IE, but not in Firefox. In FF, nothing happens on the right-click. Because of how the markup is created and rendered (i.e., each form field element is rendered inside a div, and the onclick call is inside the div), I can apply a little workaround for FF by adding a very small amount of right padding to each form element div, so if I right click just barely outside the right edge of the form field (but apparently still inside the div), the popup menu works. This will probably be a pain for my users, and I want to find a better solution so as not to discourage FF users. BTW, I can't really mess much with the way the form elements are rendered in general. Any ideas?? Is this a FF feature/bug? Thanks in advance for any help.

- Brave Soul
BraveSoul is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2006, 06:40 AM Re: Firefox does not honor right-click over disabled fields
sacx13's Avatar
Experienced Talker

Posts: 32
Location: Here
Trades: 0
FF is just complain the standard . Probably for IE it is a bug (now feature)

Regards
Adrian
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
sacx13 is offline
Reply With Quote
View Public Profile
 
Old 04-14-2006, 06:56 PM Re: Firefox does not honor right-click over disabled fields
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
BraveSoul I'm not sure about the specific answer to your question though I'm inclined to agree with sacx13 in that it's probably the way it should work.

One thing to consider is that it's generally not a good idea to overwirte the context menu. People don't like when you mess with things they're used to. I can't speak for everyone, but if I were to come to a site and discovered it had overwritten my context menu my next action would be to leave the site and never return.

It obviously will depend on who your visitors are, but I'd suggest being careful and reconsidering before changing the default context menu.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 04-14-2006, 07:44 PM Re: Firefox does not honor right-click over disabled fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
How the context menu works is not a standard either, how and what the menu contains is OS and browser dependant.

I agree with vangogh, it's not a good idea for a public website to change the functionality that users have got used to.

The only time you may be on (relatively) safe ground with this would be on an intranet where you know what browser/OS the viewer will be using.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-14-2006, 09:30 PM Re: Firefox does not honor right-click over disabled fields
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
This is a bug in Firefox. Disabled elements should still fire events of the container through either capturing or bubbling.

To get around it, you'll have to "pseudo disable" the elements. When they are disabled, attach an event handler to the fields "change" event. When the field is changed, revert it back to it's previous state. Perhaps give the field some styling (like greying the background or something) that will visually tell the user it is disabled.

For example (demonstration, not tested):
Code:
function disableField(field)
{
    field.disabled_value = field.value;
    field.oncahnge= fieldChanged;
    field.style.backgroundColor = '#555';
}

function enableField(field)
{
    field.onchange = null;
    field.style.backgroundColor = '';
}


function fieldChanged()
{
    this.value = this.disabled_value;
}
As for the act of replacing or disabling right-clicking: I agree with the above. Unless it is an editor of some sort (ie. like a control panel for an app), or an intranet like chrishirst pointed out -- it's generally a bad idea. It can't be reliable, and it's annoying. It might be worth moving the right-click menus' functionality somewhere more accessible.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 04-18-2006, 01:01 AM Re: Firefox does not honor right-click over disabled fields
Junior Talker

Posts: 3
Trades: 0
Thanks, everyone, for replying to my post. Special thanks to Chroder for identifying this bug and pointing me to the link. To explain a little further, I understand that the casual visitor to a site may be very annoyed if the context menu was overridden, including myself. But the site I'm involved with is a restricted access web application site, and the functionality I'm trying to provide will be something the users will need and like. Besides, I only override the context menu when it is a form element container (div) that they right-click on. If they right-click away from a form element, the normal context menu works. BTW, does anyone know how long it may take for bugs of this nature to be fixed in FF? Thanks again.
- Brave Soul
BraveSoul is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Firefox does not honor right-click over disabled fields
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24275 seconds with 12 queries