Created
March 19, 2010 20:47
-
-
Save anotheremily/338164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* creates javascript that causes links with the class newWindow to open in a new browser window | |
* requires mootools v1.24 (core) | |
*/ | |
"use strict"; | |
function createLinkTargets() { | |
$(document.body).getElements( 'a.newWindow').each( function( el ) { | |
el.addEvent('click', function () { | |
var newWindow = window.open(el.getAttribute('href')); | |
el.href = '#'; | |
return false; | |
}); | |
}); | |
return; | |
} | |
window.addEvent('domready', function () { | |
createLinkTargets(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment