Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anotheremily/338164 to your computer and use it in GitHub Desktop.
Save anotheremily/338164 to your computer and use it in GitHub Desktop.
/**
* 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