Open external links in a new window (WordPress plugin)

Description

This WordPress plugin pens all external links (starting with http:// or https://) in a separate browser window. The plugin produces XHTML Strict compliant code and is also search engine optimized (SEO).

This is done using JavaScript’s window.open()-function.

Most other plugins perform a hack by altering the target parameter (i.e. <a href="http://somewhere.example" target="_blank">). That method is not XHTML Strict compliant. This plugin handles the links client-side, which lets search engines follow the links properly. Also, if a browser does not support JavaScript, the plugin is simply inactive, and does not result in any errors.

Credits

Based on the source of Zap_NewWindow by Tom Köhler. Thanks a lot!

Download

The plugin can be downloaded through WordPress’s repository.

Support

If you have questions, please write in the WordPress forums or contact me by using the form below.

4 thoughts on “Open external links in a new window (WordPress plugin)

  1. Open external links in a new window Plugin
    I am trying to include sub domains as part of the $blogdomain variable so they will not open in a new window. Can you help?

    • Since some top level domains have an additional levels (e.g. .co.uk), I would have to go through this will all domain names… And I don’t want to.

      If you figure out an easy way to do it, please send me your updated source code.

  2. He Kristian, your Plugin works really good but in my case it´s causing following problem:
    in combination with different “thickbox” plugins after clicking on images the image opens in a new window and additionally with the thickbox function in the same window!?
    I´m using amazons S3 content dilevery network. Maybe that´s the problem!?

    Here are links for you to check the problem. Click on the image and you can see what happens:
    http://www.golfball-uhu.de/2011/11/golfball-uhu-jetzt-auch-fur-iphone-co-optimiert/
    http://www.golfball-uhu.de/wie-funktioniert-der-uhu/

    Hope you can help me :-)

Skriv et svar

Din e-mail-adresse vil ikke blive offentliggjort. Krævede felter er markeret med *

*

Disse HTML koder og attributter er tilladte: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>