Return to Snippet

Revision: 25434
at March 30, 2010 17:48 by birnamdesigns

Initial Code
window.addEvent('domready', function() {
    // modified from 
    // to avoid using the 'target' attribute, which is not part of xhtml 1.0 strict
    var currentDomain =;
    $(document.body).addEvent('click', function(evt) {
	var 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)) {'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

Initial Language