Posted By

chrisdpratt on 09/11/09


strict external target

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


jQuery Targets for External Links in XHTML 1.0 Strict

 / Published in: jQuery

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.

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

Report this snippet  

You need to login to post a comment.