Revision: 25434
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 30, 2010 17:48 by birnamdesigns
Initial Code
window.addEvent('domready', function() { // modified from http://joesong.com/2009/11/external-links-in-new-window-passive-and-with-mootools/ // to avoid using the 'target' attribute, which is not part of xhtml 1.0 strict var currentDomain = window.location.host; $(document.body).addEvent('click', function(evt) { var target = $(evt.target); if (target.get('tag') !== 'a') { target = target.getParent(); } if (target && target.get('tag') === 'a' && target.get('href').test('http') && !target.get('href').test(currentDomain)) { window.open(target.get('href'), '_blank'); return false; } }); });
Initial URL
Initial Description
The html attribute 'target="_blank"' for links is no longer valid code as of XHTML Strict 1.0. This code will run using mootools on domready to send all clicks to new windows when going to an external domain.
Initial Title
automatically send external links to new window with mootools
Initial Tags
links
Initial Language
JavaScript