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.

28 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.

  7. Hej Kristian,

    Jeg har hentet dit plugin og installeret det.

    Jeg har dog et problem. Når jeg tilføjer et link til at åbne i et nyt vindue, fungerer det fint. Linket åbner i et nyt vindue. Problemet er bare, at kildesiden stadig ryger hen på link. Dvs. at jeg har to åbne sider, der er identiske.

    Har du nogen idé om, hvad der trigger det problem? Min side er Stayclassy.dk

  8. Hej Kristian
    Jeg har en WP side hvor jeg benytter dit plugin til external links.

    Jeg kunne godt tænke mig at vide om du har en ide til hvortil jeg kan gøre så jeg i mine blog indlæg altid åbner links på en ny side uden at skulle sætte ticker i funktionen på hvert eneste link :)

    Kan dit plugin dette?

  9. Hi Kristian,

    I’m using your plugin on a Divi Theme site. It doesn’t work no matter what link I specify to open in a separate window, or leave the field blank. Does this plugin just not work with my theme?

  10. Hello Kristian, I was wondering how to input 2 URLs in the plugin, currently, only the first one I enter, works.
    Thanks!

  11. I am new to website design and WordPress.
    I want to sell bespoke embroidery designs and handmade bags. In the latter, I would like the visitor to my site to be able to click a link to another store site in order to choose one of their fabrics for the bag. When (or before) they close the window, I’d like to capture to url of the last page they visited (i.e. their choice of fabric).
    When they have finished choosing the other possible modifications, I’d like the order sent to me with a list of what they have chosen including the link to the fabric so I can order it. Does that make sense?

Skriv et svar til Elsie Annuller svar

Din e-mailadresse vil ikke blive publiceret.