How can I open a link in a new window?

I have a click handler for a specific link, inside that I want to do something similar to the following:

window.location = url

I need this to actually open the url in a new window though, how do I do this?


Solution 1:

You can like:

window.open('url', 'window name', 'window settings')

jQuery:

$('a#link_id').click(function(){
  window.open('url', 'window name', 'window settings');
  return false;
});

You could also set the target to _blank actually.

Solution 2:

Here's how to force the target inside a click handler:

$('a#link_id').click(function() {
    $(this).attr('target', '_blank');
});