/ Published in: jQuery
The most annoying thing I find working with the strict doctype is the inability to send users off to a site in a new window.
To combat this, I always use the above snippet.
Some people just stick the attribute on the anchors when the page loads, however for semi-accessibility, I think this works well.
To combat this, I always use the above snippet.
Some people just stick the attribute on the anchors when the page loads, however for semi-accessibility, I think this works well.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('a.ext').each(function() { var $self = $(this), extTitle; if ($self.attr('title') !== undefined && $self.attr('title') !== "") { extTitle = $self.attr('title'); $self.attr('title', extTitle + ' (opens in a new window)'); } else { $self.attr('title', 'This link will open in a new window'); } }).bind({ 'click':function() { window.open($(this).attr('href')); return false; }, 'keypress':function(e) { if (e.keyCode == 13){window.open($(this).attr('href')); return false;} } });