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.

18 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?

  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 :-)

  3. Hi Kristian. I’ve configured to force links open in a new window if they match “/go/” and it works nicely. However, when there are different “/go/” links in a post, only one will work and the other one will be blocked by my browser’s pop-up blocker.

    Can you visit to this post and have a look? “Exabytes” is the one that works, while “HostGator” is the one being blocked by browser’s pop-up blocker.

    And “/go/” is the string I added to the force link to open in new window setting.

    Thanks in advance.

  4. Hej kristian

    Jeg har søgt – og søger stadig – efter et WP plugin der gør det nemmere at få f.eks. en pdf til at åbne op i “new window” … savner denne funktionalitet meget meget ofte

    Forstår ikke hvor der ikke er mulighed for et “open in new window”-flueben i Mediebibliotekets “Attachment Display Settings”

    … jeg faldt over dit plugin som ser fedt ud … men desværre ikke var løsningen på mit problem.

    Jeg ved at denne funktionalitet er foreslået som noget der bør tilføjes til WordPress …. men om det kommer til at ske er ret usikkert (Link: https://wordpress.org/ideas/topic/add-open-in-new-window-checkbox-to-media-upload-dialog-window )

    Kunne det tænkes at du kunne have lyst til at lave et plugin der kunne løse dette prolem?

    Mvh Lars Bro

    • Det burde kunne ordnes med regular expressions. Prøv at installere plugin’et.
      Der, hvor der står “Tving links til at åbne i et nyt vindue, hvis de matcher” skal du skrive “/pdf$/gi” uden citationstegn. Så vidt jeg husker burde det virke. Ellers prøv at nøjes med at skrive “pdf”, men så rammer det også hvis du fx linker til en Word-fil der hedder “pdf.docx”.
      Giv gerne en tilbagemelding.

  5. Hej Kristian

    Tak for hjælpen ….. der skulle stå “pdf” (uden citationstegn og /) …. og det virker :-)

    Mvh Lars Bro

    PS. “/pdf$/gi”, “/pdf$/”, “/pdf/” virkede ikke ;-)

  6. Open external links in a new window, just downloaded but works ONLY with ONE link, as soon as you input more than one then it stops working. Too bad. Would even pay for this plugin if it was working.

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *