title: right click on html link which execute javascript
body: <p>When i click a link, i want to execute a javascript function to get the dynamic url.
  So i did like below.</p>
  
  <pre><code>&lt;a href="javascript:myredirect()"&gt; a link &lt;/a&gt;
  </code></pre>
  
  <p>With this code, I cannot see the default context menus provided by browsers like 'open link in new tab' or 'open link in new window' when i right click the link.
  I tried like below too.</p>
  
  <pre><code>&lt;a href="#" onclick="myredirect()"&gt; a link &lt;/a&gt;
  </code></pre>
  
  <p>In this case, i can see the link context menu, but it does not execute the "myredirect()" when i do the 'open link in new tab' menu.</p>
  
  <p>Is there a way to run a javascript code when i open link in new tab or new window?</p>