html tutorial - onshow Attribute in HTML - html5 - html code - html form




Onshow attribute in html

Learn html - html tutorial - Onshow attribute in html - html examples - html programs

  • The onshow attribute trigger an event when a <menu> element is displayed as a context menu.

Syntax for onshow attribute in HTML:

<menu onshow=”script”>

Differences between HTML 4.01 and HTML5 for onshow attribute:

HTML 4.01

  • The <menu> tag was deprecated in HTML4.

HTML 5

  • HTML5 redefined the <menu> tag.

Applies To:

Element Attribute
<menu> onshow

Attribute Values:

Value Description
script The script can run on onshow

Sample Coding for onshow Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
         <title>Wikitechy onshow attribute</title>
    </head>
    <body>
      <div style="background:cyan;padding:20px;" contextmenu="wikiContext">
      <p>Right click the box to View Wikitechy Context Menu</p>
      
      <menu type="context" id="wikiContext" onshow="onShow()">
      <menuitem label="Wikitechy" onclick="window.open('http://www.wikitechy.com');" icon="icon.png">
      </menuitem>
      <menu label="Online">
      <menu type="context" id="wikiContext">
      <menuitem label="Tutorials" icon="icon.png" onclick="window.open('http://www.wikitechy.com/online-tutorials');">
      </menuitem>
      </menu>
      </menu>
      </menu>
      </div>
      <script>
      function onShow() 
      {
        alert ("The context menu is about to be displayed");
      }
      </script>
    </body>
</html>

Code Explanation for onshow Attribute in HTML:

onshow Attribute Code Explanation

  1. Using contextmenu attribute we can create a context menu for the element.
  2. <menu> tag is used to define the list of the commands for menu list.
  3. type=” context” attribute used to specify the context menu.
  4. onshow attribute calls the JavaScript function onShow() when user try to display the context menu.
  5. The JavaScript Function onShow() shows the alert dialogue box with the message "The context menu is about to be displayed".

Output for onshow Attribute in HTML:

onshow Attribute Tag Output

  1. The output has been displayed.
onshow Attribute Tag Output

  1. Right click the box, the alert box has been.
onshow Attribute Tag Output

  1. After clicking the OK button in the alert box, the contextmenu has been displayed.

Browser Support for onshow Attribute in HTML:

No No 8.0 No No

Related Searches to onshow Attribute in html