[Mediawiki-l] External Link Opening in New Tab or Window

Charlie Markwick charlie-markwick at southcot.com
Mon Jan 24 12:13:44 UTC 2011


-----Original Message-----
From: mediawiki-l-bounces at lists.wikimedia.org
[mailto:mediawiki-l-bounces at lists.wikimedia.org] On Behalf Of nakohdo
Sent: 21 January 2011 19:57
To: mediawiki-l at lists.wikimedia.org
Subject: Re: [Mediawiki-l] External Link Opening in New Tab or Window

Just put the following JavaScript code in your wiki's
MediaWiki:Common.js
page:

// Anything in this function wrapper will be executed when the page is
ready
for action
( function( $ ) {
$( document ).ready( function() {
 
// Open external links in the sidebar in a new window
$( '#mw-panel, #panel' ) // #panel is for pre-1.17 compatibility
        .find( 'li a' )
        .filter( '[href^=http://], [href^=https://]' )
        .attr( 'target' , '_blank' );
} );
} )( jQuery );


Thanks I'll try that.

Charlie



More information about the MediaWiki-l mailing list