YouTip LogoYouTip

Ev Onshow

## HTML onshow Event Attribute The `onshow` event attribute is triggered when a `` element is shown as a context menu (typically activated via a right-click). --- ### Deprecation and Modern Web Standards Warning > ⚠️ **Important Note on Compatibility:** The `` element and the `onshow` attribute were introduced in HTML5 but have since been **deprecated and removed** from the HTML Living Standard. Modern browsers no longer support this native context menu API. For production-ready applications, developers should implement custom context menus using JavaScript (listening to the `contextmenu` event) and CSS. --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | *script* | The JavaScript code or function to be executed when the `` element is displayed. | --- ## Technical Details | Detail | Description | | :--- | :--- | | **Supported HTML Tags** | `` | | **HTML Version** | Introduced in HTML5 (now deprecated) | | **JavaScript DOM Equivalent** | `object.onshow = function(){...};` | --- ## Code Example (Legacy Implementation) In browsers that historically supported this feature (such as older versions of Firefox), the `onshow` attribute allowed developers to run a script right before the custom context menu was rendered. This was useful for dynamically updating menu items based on the current state of the application. ```html

Right-click inside this yellow box to view the custom context menu!

``` --- ## Browser Compatibility The numbers in the table below indicate the first browser version that fully supported this event attribute. | Event Attribute | Chrome | Internet Explorer / Edge | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **onshow** | *Not Supported* | *Not Supported* | 8.0 (Deprecated) | *Not Supported* | *Not Supported* | --- ## Modern Alternative: Custom Context Menus Because the native `` and `onshow` APIs are obsolete, you should implement custom context menus using standard JavaScript. Here is the modern, cross-browser equivalent using the `contextmenu` event: ```html
Right-click inside this box!
``` ## Related Pages * HTML DOM Reference: (https://www.w3schools.com/jsref/event_onshow.asp) (Legacy) * MDN Web Docs: [Element: contextmenu event](https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event)
← Event OnwheelEvent Ondrop β†’