MediaWiki:Gadget-extlinks.js

// Open external links in a new tab or window. $(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 === window.location.hostname || $link.attr('href').substr(0, server.length) === server ) { return; }		$link.attr( 'target', '_blank' ); }); });