简体   繁体   中英

target_blank opening the url in same tab and a new empty tab

下面的代码是在同一页面(选项卡)中打开URL,并创建一个新的空选项卡。我想在另一个选项卡或窗口中打开URL,我的页面保持不变而不更改。

<a  href="javascript:void(0);" onclick="_gaq.push(['_trackEvent', 'Apply Now', 'Click', 'Stage 1']);location.href='http://www.testlink.com/course/test11'" target="_blank">Apply now</a>

请尝试以下操作:

<a  href="#" onclick="_gaq.push(['_trackEvent', 'Apply Now', 'Click', 'Stage 1']);window.open('http://www.testlink.com/course/test11', '_blank')">Apply now</a>

Is there any reason you can't put the link in the 'href' attribute? target="_blank" will force it to open in a new window/tab.

<a href="http://www.testlink.com/course/test11" onclick="_gaq.push(['_trackEvent', 'Apply Now', 'Click', 'Stage 1']);" target="_blank">Apply now</a>

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