简体   繁体   中英

A regular link with _blank gets opened in tab but a JS window.open(url, “_blank”); open a new window?

When i use regular links with target="_blank" i get a new tab opened but when i use a JS window.open(url, "_blank"); i get a new window instead(im using it from a Response.Write()), same browser same settings, why? I need the JS to react the same way as the link!

Try inserting the link into the page and setting it's style so that it is hidden from the viewport. You would then, instead of window.open(url, "_blank"); , call $( 'link-selector' ).click(); . Note that I haven't tested it, maybe some browsers will block the new tab from being opened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM