弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the 兼容性表格 at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

HTMLElement.contextMenu property refers to the context menu assigned to an element using the contextmenu attribute. The menu itself is created using the <menu> 元素。

句法

var elementContextMenu = element.contextMenu;
					

范例

var contextMenu = document.getElementById("element").contextMenu;
// Change the label of the first menu entry
contextMenu.firstElementChild.label = "New label";
					

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
contextMenu 弃用 非标 Chrome 不支持 45 — 61 Edge 不支持 ≤18 — 79 Firefox 1 IE ? Opera ? Safari ? WebView Android 不支持 45 — 61 Chrome Android 不支持 45 — 61 Firefox Android 4 Opera Android ? Safari iOS ? Samsung Internet Android 不支持 5.0 — 8.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改:
  1. HTMLElement
  2. 特性
    1. contentEditable
    2. contextMenu
    3. dir
    4. hidden
    5. innerText
    6. isContentEditable
    7. lang
    8. offsetHeight
    9. offsetLeft
    10. offsetParent
    11. offsetTop
    12. offsetWidth
    13. onabort
    14. onanimationcancel
    15. onanimationend
    16. onanimationiteration
    17. onauxclick
    18. onblur
    19. oncancel
    20. oncanplay
    21. oncanplaythrough
    22. onchange
    23. onclick
    24. onclose
    25. oncontextmenu
    26. oncopy
    27. oncuechange
    28. oncut
    29. ondblclick
    30. ondurationchange
    31. onended
    32. onerror
    33. onfocus
    34. onformdata
    35. ongotpointercapture
    36. oninput
    37. oninvalid
    38. onkeydown
    39. onkeypress
    40. onkeyup
    41. onload
    42. onloadeddata
    43. onloadedmetadata
    44. onloadend
    45. onloadstart
    46. onlostpointercapture
    47. onmousedown
    48. onmouseenter
    49. onmouseleave
    50. onmousemove
    51. onmouseout
    52. onmouseover
    53. onmouseup
    54. onpaste
    55. onpause
    56. onplay
    57. onplaying
    58. onpointercancel
    59. onpointerdown
    60. onpointerenter
    61. onpointerleave
    62. onpointermove
    63. onpointerout
    64. onpointerover
    65. onpointerup
    66. onreset
    67. onresize
    68. onscroll
    69. onselect
    70. onselectionchange
    71. onselectstart
    72. onsubmit
    73. ontouchcancel
    74. ontouchstart
    75. ontransitioncancel
    76. ontransitionend
    77. onwheel
    78. outerText
    79. title
  3. 方法
    1. click()
    2. forceSpellCheck()
  4. 事件
    1. animationcancel
    2. animationend
    3. animationiteration
    4. animationstart
    5. beforeinput
    6. change
    7. gotpointercapture
    8. input
    9. lostpointercapture
    10. pointercancel
    11. pointerdown
    12. pointerenter
    13. pointerleave
    14. pointermove
    15. pointerout
    16. pointerover
    17. pointerup
    18. transitioncancel
    19. transitionend
    20. transitionrun
    21. transitionstart
  5. 继承:
    1. 元素
    2. 节点
    3. EventTarget
  6. HTML DOM 相关页面
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLEmbedElement
    22. HTMLFieldSetElement
    23. HTMLFormControlsCollection
    24. HTMLFormElement
    25. HTMLFrameSetElement
    26. HTMLHRElement
    27. HTMLHeadElement
    28. HTMLHeadingElement
    29. HTMLHtmlElement
    30. HTMLIFrameElement
    31. HTMLImageElement
    32. HTMLInputElement
    33. HTMLIsIndexElement
    34. HTMLKeygenElement
    35. HTMLLIElement
    36. HTMLLabelElement
    37. HTMLLegendElement
    38. HTMLLinkElement
    39. HTMLMapElement
    40. HTMLMediaElement
    41. HTMLMetaElement
    42. HTMLMeterElement
    43. HTMLModElement
    44. HTMLOListElement
    45. HTMLObjectElement
    46. HTMLOptGroupElement
    47. HTMLOptionElement
    48. HTMLOptionsCollection
    49. HTMLOutputElement
    50. HTMLParagraphElement
    51. HTMLParamElement
    52. HTMLPictureElement
    53. HTMLPreElement
    54. HTMLProgressElement
    55. HTMLQuoteElement
    56. HTMLScriptElement
    57. HTMLSelectElement
    58. HTMLShadowElement
    59. HTMLSourceElement
    60. HTMLSpanElement
    61. HTMLStyleElement
    62. HTMLTableCaptionElement
    63. HTMLTableCellElement
    64. HTMLTableColElement
    65. HTMLTableDataCellElement
    66. HTMLTableElement
    67. HTMLTableHeaderCellElement
    68. HTMLTableRowElement
    69. HTMLTableSectionElement
    70. HTMLTemplateElement
    71. HTMLTextAreaElement
    72. HTMLTimeElement
    73. HTMLTitleElement
    74. HTMLTrackElement
    75. HTMLUListElement
    76. HTMLUnknownElement
    77. HTMLVideoElement
    78. HashChangeEvent
    79. 历史
    80. ImageData
    81. 定位
    82. MessageChannel
    83. MessageEvent
    84. MessagePort
    85. Navigator
    86. NavigatorGeolocation
    87. NavigatorID
    88. NavigatorLanguage
    89. NavigatorOnLine
    90. NavigatorPlugins
    91. PageTransitionEvent
    92. Plugin
    93. PluginArray
    94. PopStateEvent
    95. PortCollection
    96. PromiseRejectionEvent
    97. RadioNodeList
    98. Transferable
    99. ValidityState
    100. Window
    101. WindowBase64
    102. WindowEventHandlers
    103. WindowTimers