[support] opening the feeds in new browser

Earnie Boyd earnie at users.sourceforge.net
Mon Aug 6 22:25:08 UTC 2007


Quoting paola.dimaio at gmail.com:

> question of the day: how do I get the aggregated feed from another site
> to open on a different windows/tab when clicked? (now it takes away
> the uzer from our site, which is bad)
>

I've used the following JS script placed just above the ending html 
body tag of the page.tpl.php file so that I don't have to worry about 
external tags.  A new window is opened if the target _external doesn't 
exist else the existing window is reused.  This prevents the user 
having "too many" open windows.

<code>
    <script type="text/javascript">
    var lnk, lnks = document.getElementsByTagName('a');
    var host = location.hostname;
    for (var i=0; lnk=lnks[i]; i++) {
      if (lnk.href.indexOf(host)==-1) {
        lnk.setAttribute('target', '_external');
      }
    }
    </script>
</code>

Earnie -- http://for-my-kids.com/


More information about the support mailing list