I am trying to have Javascript and link URL at the same time, so when user clicks the link it will have a popup first then direct to that link, what's wrong with the following?
I think the click event preempts the normal handling of the href. Just do it from within a javascript function. The property you want is document.location, or something like that.
Your example works fine for me in firefox. You should be able to control the cascading of the event manually by returning a value from the onclick:
Should always work:
<a href="foo" onclick="alert('hi'); return true;">foo</a>
Should never work:
<a href="foo" onclick="alert('hi'); return false;">foo</a>
I support the idea of not using document.location because that tends to get in the way of browser configurations that open up links in new tabs or windows (for instance, if you middle click on a link) and it also stops users from seeing where the link is taking them because it doesn't show up in the status bar.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.