so I have some <a href="..
tags on a page , they have an inline onclick
attribute. If the user clicks one and is not logged in , they will be prompted to log-in, then on the page refresh jquery will fire .click()
on the <a>
element to bring the user where they originally wanted to go.
Because of pop-up blocker issues , I made it to where if jquery triggers a .click()
I open the link in the same window.
But if the user is already logged in , I would like clicking the link to open in a new tab. This is the code I have that is working fine in Chrome , but FireFox gets mad at it - says 'event is undefined'.
<a href="#" onclick="genericActionComplete('12345', this, 'http://www.myurl.com', false, e)
function genericActionComplete(actionId, ctl, url, markComplete, e) {
if(event.x != null){ // User Clicked - open url in new tab
window.open(url);
}
else{ // Click performed by script after logIn , open in same tab to prevent Pop-Up Blocker
window.location = url;
}
}
I tried passing this
and e
and tried just using event
with no luck in firefox , I am checking for event.x because that will have a value if the user clicked the link with the mouse.