Open external links in a new window

From Richard's Wiki
Jump to: navigation, search

Opening external links in a new window

Since upgraded to version 1.17.0, just follow the instruction in the link below (add

$wgExternalLinkTarget = '_blank';

to LocalSettings.php)


The new window Wikimedia link is useful information. Probably the easiest way is:

Version > 1.5.0

  1. Open includes/Linker.php
  2. Find "function getExternalLinkAttributes"
  3. After
 $r = ($class != ) ? " class='$class'" : " class='external'"; 
 insert the following code 
 $r .= " target=\"_blank\"";

Actually did this to includes/Linker.php:

       function getExternalLinkAttributes( $title, $unused = null, $class= ) {
               ### return $this->getLinkAttributesInternal( $title, $class, 'external' );
               $r = $this->getLinkAttributesInternal( $title, $class, 'external' );
               $r .= " target=\"_blank\"";
               return $r;
       }