jquery - How to emulate click on anchor tag with javascript? -


on site, have div container, contains <input>, , <a onclick="dosomestuff();" href="#" target="_blank"> element, acts button. now, dosomestuff(); modifies href attribute based on value of input element.

i need emulate click on anchor tag after user pressed enter on input element. know how detect enter, don't know how click anchor. jquery's .click() not working in here, fires onclick() of anchor tag, not click anchor.

edit: here example on want do: http://jsfiddle.net/jzywz/. triggers onclick event of anchor tag, not follow link in new tab.

browsers strict opening links in new tabs/windows through javascript.

if allowed have javascript click , open new tab when user presses enter (for know legitimate reasons), feature abused spammers have javascript click ads , spam links when user anything. sadly there's no way browser can tell linked page legitimate , not spam or monetised clickbait.

pretty option open url in new tab using javascript window.open you've tried: browser look user's settings on popup blocking , on whether open in tabs or windows - , default settings strict, particularly in firefox , internet explorer (less in chrome , safari).


a possible alternate approach won't fighting browser's anti-spam defences open content in modal overlay (iframe-based if need multiple pages). here's 1 example library.

it'll similar ui point of view - giving user related content in form can close , return main page when they're done it.

modal overlays used , familiar users. example, they're pretty standard sharing pages, logins , other pieces of simple interaction or side content. example:

enter image description here


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -