[Mediawiki-l] How to make external links open a new window?

Brion Vibber brion at pobox.com
Wed Feb 9 08:49:01 UTC 2005

Jan Steinman wrote:
> My convention for sites I do is to make links that go off-site open a
> new window.

I think that's a bad idea, personally. ;) Users really, really hate it
when you force them to open links in a new window without expecting it.

> I tried hacking around in include/Skin.php but was unable to add
> 'target="offsite"' to any of the code that builds '<a>' tags in a way
> that would reliably appear in generated pages.

Make sure you're not looking at previously cached HTML. (A simple way to
be _really sure_ is to do the testing in an edit preview. The preview
will _always_ be rendered fresh.)

Some browsers do not re-fetch data on the 'refresh' or 'reload' command
if the server returns a 304 response. You may need to push additional
buttons to force this (try control or shift). Additionally, if the
parser cache is enabled (the default in 1.4) you may need to flush that;
use action=purge, edit the page, or clear the objectcache table (if
using the default cache backend rather than selecting memcached or turck
mmcache data cache functions).

> Specifically, I thought that adding the 'target' attribute would work
> inside getExternalLinkAttributes(), but refreshing a page with external
> links does not show the new target attribute.

Making this change does work in my testing, so check the caching issues

-- brion vibber (brion @ pobox.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : http://lists.wikimedia.org/pipermail/mediawiki-l/attachments/20050209/1b47cdeb/attachment.pgp 

More information about the MediaWiki-l mailing list