4

When I right-click on my #texte div, a contextMenu is called.

<div id="texte" >
        <p>Bla bla bla</p>
</div>

What I want to do is: to simulate the right-click on that area by clicking on another button. For example by clicking this:

<div id="otherDiv">
        <form>
            <input type="submit" value="Check" onclick="check()" />
        </form>
</div>

Is it possible?

I already tried the trigger fucntion like this:

function check() {
            $('#texte').trigger({
                type: 'mousedown',
                which: 3
            });
            //$('#btn-replace-accept_texte').trigger('click');
        }

but it doesn't work.

Thanks for your help!

Simon
  • 337
  • 1
  • 3
  • 11
  • No it's not the same problem but thanks. – Simon Aug 01 '14 at 09:50
  • Not possible with javascript. – Pramod S. Nikam Aug 01 '14 at 09:50
  • 1
    @Orion , why not possible ? jQuery / javascript is powerful – Pratik Joshi Aug 01 '14 at 09:54
  • 1
    @jQueryAngryBird You can throw all the javascript you want at the problem, but if user agents don't allow you to do it it is not possible. Not even with 1000000 lines of javascript – PeeHaa Aug 01 '14 at 09:55
  • @jQueryAngryBird - +1 for your confidence. but not possible :) – Pramod S. Nikam Aug 01 '14 at 09:56
  • Ok then if it's not possible I'll try another way! Thank you for your quick answers. – Simon Aug 01 '14 at 09:57
  • 1
    @PeeHaa not technical true, you could create a menu that appears when you right click that looks like the menu and has javascript functions that do what the menu can do. (You obviously wouldn't want to) When I right click I get Back, Forward, Reload, Save As, Print, Translate, View Source, View Info, Inspect, the majority of which can be simulated one way or another in JS. So the question is, what exactly are you trying to do? Because there is probably a JS way to do it without loading the context menu. – Dan Brown Aug 01 '14 at 09:58
  • Technically (as you state) it really is not possible because you cannot recreate all functions provided by it. But you are correct that you can create a fake content menu – PeeHaa Aug 01 '14 at 10:09

0 Answers0