/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: contextmenu

[this page | pdf | back links]

The HTML contextmenu attribute indicates the context menu (i.e. what appears when the mouse is right-clicked). At the time of writing (early 2018) it did not appear to be supported by many browsers.

 

Valid attribute values include:

 

Value

Description

text

Text to display when mouse is right-clicked

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<em contextmenu="Additional info">italic text</em>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("EM");
x.textContent = "italic text";
// or use var txt = document.createTextNode("italic text");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile