This question was already asked in a simple way here: Trigger right click using pure JavaScript, however, none of the answers there is what I (and apparently the poster of that thread) seek.
First and foremost, this question is not about events. I am not interested in knowing how to listen to a right click event (that would be a 'contextemenu' event). This is about simulating a right click on any DOM element, just by using the browsers console (chrome, in my case), and therefore JavaScript/DOM manipulation.
That been said, I know that there is a simple function to do the same thing, except it triggers a left ("normal") click, on any element. For instance, the famous...
I found out that if you look at the source code, and somehow get a reference to the checkbox element, or the "div" where it is contained, lets say you get the ID, so you create a variable like this...
myElement = document.getElementById('Id_here');
you can simulate a click just by typing this into the browsers console:
myElement.click();
And the result will be:
So, we simulated a real click, solving the captcha, no mouse needed, and more important, no human needed (if you implement this on a script)
The question now is pretty simple...
Something like myElement.rightClick(); or myElement.contextClick();?
DISCLAIMER
This is just for research and knowledge purposes only. Yes, I have searched in many sites, but they always talk about the event, nothing like what I'm asking for. I would appreciate it a lot if anyone could answer this question, even if the answer is "No, you can't ". However, if you are going to state that, please be 100% sure that it is not possible or plausible. As always, thanks in advance!
Yap easy:
var element = document.getElementById('Id_here');
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');
}