开发者

Keeping the native style of a context menu in webpages

I know everyone hates when their context menus get messed with so what I'm asking for is the opposite of that. I've tried looking for javascript plugins that deal with changing the context menus in webpages, but I find that they are very intrusive. (i.e. the context menu now开发者_开发问答 only contains the items that the developer chooses). Is there a way to simply add an item to the context menu, all while keeping the user's normal items and at the same time keeping the native style of the menu? The same plugins I have found require the developer to define a new style for the menus. I don't see the point in reinventing the wheel.

I ask because a client of mine wants to add extra functionality to the site when the user right clicks.


  • The context menu can't be modified via normal javascript + DOM. It (usually) can be suppressed and replaced by some dynamic HTML that looks and acts like a context menu. This is why the styling appears different, and why you can't combine built-in and custom context menus... 'context menus' done in javascript are not really context menus at all.

  • The context menu may be disabled if the event is cancelled, but that's up to the browser -- most browsers provide an option to disallow hiding the context menu; if that's enabled then even if the event is cancelled the menu will show. This results in two "context menus" displaying, the real context menu and the faked-up javascript one.

  • To style web pages based on the user's system appearance, use the system colors defined in CSS2 ( http://www.iangraham.org/books/xhtml1/appd/update-23feb2000.html ) and/or the CSS3 appearance property ( http://www.w3.org/TR/2004/CR-css3-ui-20040511/#system )

Edit: In response to "a client of mine wants to add extra functionality to the site when the user right clicks" -- you might want to advise the client that they should only do this if the site is a web application (for example like google docs) where users would reasonably expect the context menu to do something out of the ordinary. You should also make sure that there is a non-hidden way to do everything that can be done via the context menu.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜