0

enter image description here

I would like to ask as to how to capture a context menu item? Currently I have a <form> and a hyperlink. What I'm planning to do is when the user right-clicks the link and selects either "Open in new window" or "Open in new tab", the form.submit method will be fired.

Here's a sample "idea" code

HTML

<form id='MyForm' method='post'>
  <div>
    <a id='MyLink' href="#">Click Me</a>
  </div>
</form>

JQuery

$("#MyForm").submit(function(){
  // if a standard context menu item is selected (open in new tab/window)
  if(true) {
    this.target = "_blank";
  }
  else {
    this.target = "MyForm";
  }

  this.action = "MyNewPage.aspx";

  //Do something here
});
Musikero31
  • 3,115
  • 6
  • 39
  • 60
  • I don't believe this is possible. JS is not notified about low level menu actions. – Rory McCrossan Jan 06 '16 at 11:17
  • want to close this question as seems to be a duplicate but didn't found one. – Jai Jan 06 '16 at 11:20
  • @Jai closest I found was [this](http://stackoverflow.com/questions/850058/is-it-possible-to-detect-if-a-user-has-opened-a-link-in-a-new-tab) but it's about detecting if the page was opened in a new tab, not knowing from the parent window if the link spawned a child tab. – Rory McCrossan Jan 06 '16 at 11:22
  • agree with @RoryMcCrossan check http://stackoverflow.com/questions/15944572/detect-right-clicks-open-in-new-tab-on-link-in-jquery – Dhara Jan 06 '16 at 11:24

0 Answers0