We help IT Professionals succeed at work.

Opening internal links (e.g. to pdf documents) in a new window.

Hi,

I have added the line $wgExternalLinkTarget = '_blank' to LocalSettings.php so that external links open in a new windows and this works fine.  I also want to open internal links, e.g. PDF links in the same way.  Is there an easy solution to this, similar to external links?
Comment
Watch Question

Hi,

The way PDF open is based on user browser settings and you don't have control on that.
This setting can also be set in software settings for example PDF reader may have a setting for that.

If the PDF is already generated and located on your server then
<a href="myfile.pdf" target="_blank">

Open in new window

will work or not depending of the user settings.

Author

Commented:
Hi Lenamtl,

Thanks for your response.

On the MediaWiki page the pdf is added in the following format:
==== [[Media:PDF Name Here]] some other text here ====

How do I apply the tags in your answer to the existing format?

Author

Commented:
Problem solved.

I needed to install an extension (LinkTarget), modify the localsettings.php file with the code below:

#Add Link Target
require_once "$IP/extensions/LinkTarget/LinkTarget.php";
$wgLinkTargetParentClasses = array( 'ext-link' );

and then wrap the media link with a span tag.

<span class="ext-link"> [[Media:MyFile.pdf|My Link Text]] </span>

Opens in a new tab now.
Commented:
Problem solved.

I needed to install an extension (LinkTarget), modify the localsettings.php file with the code below:

#Add Link Target
require_once "$IP/extensions/LinkTarget/LinkTarget.php";
$wgLinkTargetParentClasses = array( 'ext-link' );

and then wrap the media link with a span tag.

<span class="ext-link"> [[Media:MyFile.pdf|My Link Text]] </span>

Opens in a new tab now.