Return to Snippet

Revision: 17646
at September 11, 2009 10:53 by chrisdpratt


Initial Code
$(document).ready(function () {
  $('a[rel~=external]').attr('target', '_blank');
});

Initial URL

                                

Initial Description
XHTML 1.0 Strict does not allow the target attribute on links. The recommended way of specifying external links is to give the link a rel attribute of "external". This jQuery snippet finds likes with rel attributes of "external" and dynamically adds a target attribute of "_blank" so they will open in a new tab/window while maintaining valid XHTML 1.0 Strict code.

Initial Title
jQuery Targets for External Links in XHTML 1.0 Strict

Initial Tags

                                

Initial Language
jQuery