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

Jan Steinman Jan at Bytesmiths.com
Wed Feb 9 07:56:00 UTC 2005


My convention for sites I do is to make links that go off-site open a 
new window. Is there a simple way to do this? If not a simple way, 
where should I begin?

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.

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. Likewise, putting it 
inside the 'if($nt->isExternal()' in makeLinkObj() didn't seem to work.

  I suspect there's some caching going on that was masking what I was 
doing. Or is there a simpler way, perhaps in the skin CSS file?

:::: In the current US political climate, accurate bad news is punished 
and false good news rewarded. -- DarkSyde, aka John Springer
:::: Jan Steinman http://www.Bytesmiths.com/Van




More information about the MediaWiki-l mailing list