srikanth s
srikanth s

Reputation: 147

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

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

Answers (2)

Tom Bowers
Tom Bowers

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

UweB
UweB

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

Related Questions