html - 如果不推荐使用 contextmenu 如何替换它?

标签 html css

我听说上下文菜单已弃用:https://html.spec.whatwg.org/multipage/obsolete.html#attr-contextmenu

那么,有没有办法替代呢?

最佳答案

As the feature was not that popular, it is no longer supported. :

The support for HTML5 context menus, introduced with Firefox 8, will be removed soon. Other browser vendors were not interested in the feature, and therefore it has already been removed from the HTML spec, leaving Firefox as the only browser implementing the and elements as well as the contextmenu global attribute.

If desired, you can instead create your own context menu as seen in some rich web applications like Google Drive. The WAI-ARIA standard provides a way to create accessible menus which is highly recommended.

您可以使用 ARIA 创建自己的菜单。 而不是 <menu> & <menu-item>您使用普通列表(<ul> & <li>),装饰它们并使用 JS 来实现功能。 您会发现更多细节和预设 herehere .

关于html - 如果不推荐使用 contextmenu 如何替换它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57424197/

相关文章:

html - 如何使用 CSS 更改默认按钮边框?

javascript - Bootstrap 导航栏切换不渲染

html - 导航栏中的 Bootstrap 4 导航丸

jquery - 在 jQuery UI Accordion 上使用 CSS 删除此 "glare"

android - html5立即捕获照片(&lt;input/>)而不要求选择现有照片

javascript - 仅滚动到 anchor /覆盖滚动

html - Selenium - 无法选择带有 id 的输入框

Javascript 运行两次而不是一次

css - 为什么标题工具提示不适用于 float 元素?

html - CSS 选择器 : Is there any way to select the last element which has the same class name in the whole html?