Valid (X)HTML Strict with external links

/ Published in: jQuery
Save to your folder(s)

Uses jQuery to give links with rel=\"external\" the ability to open in a new window, while keeping the document XHTML or HTML Strict. Works by assigning a \"_blank\" value to the \"target\" attribute of all such links after the page has already loaded.

Copy this code and paste it in your HTML
  1. $(function() {
  2. $('a[rel^=external]').each(function() {
  3. $(this).attr('target', '_blank');
  4. });
  5. });

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.