Problem 1: I made my own contextmenu using the following code snippet.
function addFullScreenMenu () { var menu = document.createElement('menu'); var item = document.createElement('menuitem'); menu.setAttribute('id', 'fsmenu'); menu.setAttribute('type', 'context'); item.setAttribute('label', 'Fullscreen'); item.addEventListener('click', function (e) { if (window.fullScreen) { document.body.mozCancelFullScreen(); } else { document.body.mozRequestFullScreen(); } }); menu.appendChild(item); document.body.appendChild(menu); document.body.setAttribute('contextmenu', 'fsmenu'); }
Problem: It works in firefox , but does not work in GoogleChrome(Version 21.0.1180.81) .
What corrections must be made so that it does not fail in Googlechrome
Problem 2: Capturing a right-click event with an EventListener
the code:
<script type="text/javascript"> if (document.addEventListener) { document.addEventListener('contextmenu', function(e) { alert("You've tried to open context menu"); //gets alerted in firefox and googlechrome e.preventDefault(); }, false); } else { document.attachEvent('oncontextmenu', function() { alert("You've tried to open context menu");//gets alerted in Internet explorer window.event.returnValue = false; }); } </script>
Problem: EventListener for right-clicking does not work in Internet Explorer (version 9)
Update . I can solve the phx problem with phx. A solution to the problem is required.
javascript cross-browser google-chrome contextmenu menuitem
Nagaraju
source share