windows - How to right click from javascript -
it seems not possible emulate right click in javascript.
i have tried right click element (paragraph) in iframe this:
html
<button onclick="popup_context_menu_in_iframe()"> popup menu </button> <br/><br/> <iframe srcdoc="<p>hello world!</p>"> </iframe>
script
function popup_context_menu_in_iframe() { var $element = $('iframe').contents().find('p'); var element = $element.get(0); if (window.customevent) { element.dispatchevent(new customevent('contextmenu')); } else if (document.createevent) { var ev = document.createevent('htmlevents'); ev.initevent('contextmenu', true, false); element.dispatchevent(ev); } else { // internet explorer element.fireevent('oncontextmenu'); } }
https://jsfiddle.net/sca60d64/2/
it seems impossible make context menu appear need find other ways.
i first headed @ creating chrome extension add function window object, callable script using power it.
however, chrome extension surprisingly seems not provide me way of creating functions in window object. have not taken if gives me power popup context menu.
i did not experiment lot chrome extensions before giving on that.
so need solution.
it doesnt matter if solution works in google chrome or if there no guarantee stop work in next version.
should hook chrome process dll? it?
you can call dll exe file in chrome extension through native messaging. have provided sample of native messaging procedure in answer: see answer of question
i hope useful.
Comments
Post a Comment