HTML | DOM onshow Event
Last Updated :
20 Jul, 2021
The onshow event occurs when a user right click on en element and <menu> element is shown as a context menu.
Supported Tags
Syntax:
<element onshow="Script">
object.onshow = function(){Script};
- In JavaScript, using the addEventListener() method:
object.addEventListener("show", Script);
Example: Using the addEventListener() method
html
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM onshow event
</ title >
</ head >
< head >
< style >
</ style >
</ head >
< body >
< center >
< h1 style = "color:green" >
GeekforGeeks
</ h1 >
< h1 contextmenu = "Mmenu" >
HTML DOM onshow event
</ h1 >
< menu type = "context"
id = "Mmenu" ></ menu >
</ center >
< script >
document.getElementById(
"Mmenu").addEventListener("show", GFGfun);
function GFGfun() {
alert("Context menu");
}
</ script >
</ body >
</ html >
|
Output:
Before:
After right-click:
Supported Browsers: The browsers supported by HTML DOM onshow Event are listed below:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...