Reputation: 147
The code below is opening the url in the same page(tab) and also creates a new empty tab.I want to open the url in another tab or window and my page remains same without changing.
<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>
Upvotes: 1
Views: 1394
Reputation: 5140
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>
Upvotes: 2
Reputation: 4110
Try the following:
<a href="#" onclick="_gaq.push(['_trackEvent', 'Apply Now', 'Click', 'Stage 1']);window.open('http://www.testlink.com/course/test11', '_blank')">Apply now</a>
Upvotes: 1