Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <p>Right Click anywhere to see a customized context menu other than the default one in the browser!</p> </div> <div> <div id="contextMenu" style="display:none; position:absolute; background-color:white; border:1px solid black; padding:10px;"> <ul> <li>Refresh</li> <li>Save Page</li> <li>Search</li> </ul> </div> </div> <script> document.addEventListener('contextmenu', function(event) { event.preventDefault(); let menu = document.getElementById('contextMenu'); menu.style.display = 'block'; menu.style.left = `${event.clientX}px`; menu.style.top = `${event.clientY}px`; }); document.addEventListener('click', function() { document.getElementById('contextMenu').style.display = 'none'; }); </script>