Tuesday, July 30, 2013

How to Open External Links In a New Window Using Mootools

Here full code to open links in a new window using Mootools Framewok:

window.addEvent('domready',function() {
var links = $(document.body).getElements('a[href^=http:]'); //link start with http != mailto
links.each(function(el){
el.addEvent('click', function(e){
e.stop();
(this.href.test('/'+window.location.host+'/')) ? window.open(this.href):window.open(this.href, '_blank');
});
});
}); // domready


Disqus Comments