Jump to content

Topic on Extension talk:LinkTarget/Flow

Not only interwiki links open in a new tab

3
Summary by Elcapitan68

The extension modifies target attribute value in descendants of elements of the class specified in $wgLinkTargetParentClasses.

Rob Kam (talkcontribs)

I'd like to have interwiki links open in a new tab but now even wikilinks are opening in a new tab?


In LocalSettings.php (for a wiki farm):

// LinkTarget

'wgLinkTargetParentClasses' => [

'default' => [],

'simpleelectronicswiki' => ['_blank' => [ 'extiw' ]]

]

Rob Kam (talkcontribs)

Adding this instead, to MediaWiki:Common.js seems to be a solution.


// Add target="_blank" to links with class "extiw" or "external text"

$(document).ready(function() {

$("a.extiw").attr("target", "_blank");

});

Elcapitan68 (talkcontribs)

@Rob Kam Thank you for your message. JS solution works fine, as it is applied to the correct element. Leaving aside the syntax of the variable, when you use LinkTarget, you are expected to specify parent element class rather than link class.