Mediawiki open external links in a new window

Xianlin picture Xianlin · Mar 26, 2012 · Viewed 14.4k times · Source

I want to enable opening external links in a new window function in Mediawiki. I tried to modify the "LocalSettings.php" file according to the below instructions:

http://www.mediawiki.org/wiki/Manual:Opening_external_links_in_a_new_window

But I still couldn't get it working. When I looked up in the above link "Discussion" wiki page I found more informations which confused me. Any idea how to set this work in a simple and straightforward way?

Answer

Dror S. picture Dror S. · Jun 25, 2012
  • If you want a few specific links to open in a new window: You can use the LinkTarget extension. You can then surround the appropriate links with an HTML element with a class of your choosing and get the extension to handle them.

    (tor's answer also had a relevant extension linked, but Wikia removed that extension and it probably will not be maintained).

  • If you want all external links to open in a new window: MediaWiki already has a setting for it: $wgExternalLinkTarget. Just add the following to your LocalSettings.php file:

    $wgExternalLinkTarget = '_blank';
    

    Do keep in mind that some internal links might not be identified as such, and therefore will open in a new window; one such example is an internal edit link created by using

    [{{fullurl:Main Page|action=edit}}]
    


Link: $wgExternalLinkTarget on MediaWiki.org