• As reported by W3C some time ago, target=”_blank” is not good authoring and will have an impact.

    I wonder if you could, instead, implement a jscript function to open external links in a new window.

    -Scott

Viewing 5 replies - 1 through 5 (of 5 total)
  • Before:
    external link
    After:
    external link

    function externalLinks() {
      if (!document.getElementsByTagName) return;
      var anchors = document.getElementsByTagName("a");
      for (var i=0; i<anchors.length; i++) {
       var anchor = anchors[i];
       if (anchor.getAttribute("href") &amp;&amp;
         anchor.getAttribute("rel") == "external")
        anchor.target = "_blank";
      }
     }
     window.onload = externalLinks;

    As this is the kind of script you’ll want to deploy across your entire site, you should copy this code into a separate file (e.g. external.js), and then load it in every page on your site with the following code, which should appear in the <head> tag of each document:
    <script type=”text/javascript” src=”/external.js”>
    </script>

    oops

    where it said

    external link

    external link

    its supposed to say

    Before:
    <a href="document.html" target="_blank">external link</a>
    After:
    <a href="document.html" rel="external">external link</a>

    Thread Starter cableghost

    (@cableghost)

    Thank you!

    When you say add the script inside the Head section of each document, does that mean every php file that has a head section? For my theme, I’m wondering if I could just add it to my header.php

    -Scott

    that’s what it means translated into WP – header.php – these are quotes from an old article

    Thread Starter cableghost

    (@cableghost)

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘target=”_blank”’ is closed to new replies.