Aggregator links in new window with jQuery

Last modified: August 23, 2009 - 22:38

Rather than override the aggregator functions, I used jQuery to do this instead. It works great for me.

You'll need to add this to your template file either in a javascript file or directly on a template file.

/* find all aggregator links that have 'http' within the href and add a target */
$(document).ready(function(){
if($("#aggregator a[@href*=http]")[0]) {
$("#aggregator a[@href*=http]").each(function(i) {this.target = "aggwin";});
}
});

So far, it catches all the different external links and that's less of the core that I don't have to worry about.

Note that if it is not working in some instances, particularly for anonymous users, it may be because nothing else in the page is calling the core Drupal JavaScript. You may need to add a hard-coded call to misc/jquery.js in page.tpl.php.

 
 

Drupal is a registered trademark of Dries Buytaert.