Link to home
Start Free TrialLog in
Avatar of vjstech
vjstechFlag for Malta

asked on

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?
Avatar of lenamtl
lenamtl
Flag of Canada image

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.
Avatar of vjstech

ASKER

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?
Avatar of vjstech

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of vjstech
vjstech
Flag of Malta image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial