What’s the best way to open new browser window?

I am using the last method you proposed. I add rel=”external” or something similar and then use jQuery to iterate through all links and assign them a click handler:

$(document).ready(function() {
  $('a[rel*=external]').click(function(){
    window.open($(this).attr('href'));
    return false; 
  });
});

I find this the best method because:

  • it is very clear semantically: you have a link to an external resource
  • it is standards-compliant
  • it degrades gracefully (you have a very simple link with regular href attribute)
  • it still allows user to middle-click the link and open it in new tab if they wish

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)