MediaWiki:Gadget-extlinks.js

// Make external links open in a new tab or window. Why someone would want this i have no idea. Adapted from wikibooks page with same name. $(document).ready( function($) {	var server = mw.config.get( 'wgServer' );	mw.util.$content.find('a').each( function { var $link = $(this); if ( !$link.hasClass( 'external' ) && !$link.hasClass( 'extiw' ) ) { return; }		// check hostname first where available as second test may not catch all links that it should if ( this.hostname === location.hostname || $link.attr('href').substr(0, server.length) === server ) { return; }		$link.attr( 'target', '_blank' ); }); });