When i click a link, i want to execute a javascript function to get the dynamic url. So i did like below.
<a href="javascript:myredirect()"> a link </a>
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.
<a href="#" onclick="myredirect()"> a link </a>
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.
Is there a way to run a javascript code when i open link in new tab or new window?