How to edit the RSS widget to make links open in new window (2 posts)

  1. heywood
    Posted 9 years ago #

    How can I edit the rss widget so that clicking a link contained withing the rss will open up a new window ?

  2. Generally speaking, the Web 2.0 world frowns on attempting to force the browser to use new windows and such. This is why target has been removed from XHTML 1.0 Strict. It's still there (but deprecated) in Transitional, but it's frowned upon. Doesn't work with a lot of modern browsers anyway (Firefox) as these browsers often redirect new windows to Tabs or whatever.

    Still, you can try to do it with a bit of javascript. Try putting this into your theme's header (inside the <head> tags):

    <script type="text/javascript">
    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") &&
           anchor.getAttribute("class") == "rsswidget")
         anchor.target = "_blank";
    window.onload = externalLinks;

Topic Closed

This topic has been closed to new replies.

About this Topic