Dimitri Vorontzov Dimitri Vorontzov - 1 year ago 142
jQuery Question

jQuery: go to URL with target="_blank"

I am using this bit of jQuery code to get href of the link:

var url = $(this).attr('href');

-- and this bit of code to go to that href:

window.location = url;

Everything is just the way I want it, except the new page opens in the same window as the previous one, and I want it to open in a new window or tab (something that in plain html would have been achieved by using target="_blank" formula).

Question: How can I open the href in the new window or tab with jQuery?

Thank you for your help!

Answer Source

You need to open a new window:



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download