morssload - read remote rss and load it into your page.

If you feel an urge to contact me you can do so from this page

EN

! As this script uses xmlhttp and security restrictions do not allow another server (other than the page originates from) to be accessed, a small cache/proxy (written in php) has to be used. Another way is if you already have a way to download all the rss files to your server you can point the script directly to the files.

This script can be used to easily display the rss xml from another site into your site. Does not require a knowledge of server side programing but as I have created the "proxy" in php your ISP should support php.
XMLHTTP was used to access the rss proxy server. There are always quite interesting scope issues if you want to have a separate event handler for events as it is executed in the global scope.

Instalation and usage:
  • Server:
    Put rssproxy.php in a directory on your site and create a "data" directory where it will store the downloaded rss feeds. Make sure the directory is writeable by the script. The name of the dir is defined in this line of rssproxy.php:
    define( 'CS_RSS_DATA_DIR', 'data' );

    The feeds are cached for 10 minutes (if a feed is older than 10 minutes it's downloaded again) but this is also controlable by seting this
    define( 'CN_RSS_UPDATE_INTERVAL', 10*60 );

    10*60 means 10 minutes multiplied by 60 seconds.

  • Client: (you can always view the source of this page or read the source in the zip file)
    Create an element on your page that has the rss attribute set to:
    rss="path-to-rss-proxy/rssproxy.php?file=http://slashdot.org/index.rss"
    http://slashdot.org/index.rss - is the url of the rss feed and you can put there whatever you like.

    Additional attributes that control the script's behaviour:
    rssdisplay="links|descriptive"
    links means to display only the links to the articles and descriptive means to display the description too

    rsstarget="_self|_blank|_top|frame_name"
    this is what the target attribute of all links within the block will be set to. set it to whatever a valid target attribute you want

    onrssload="onRssLoad(this)"
    Set this to a call back function (use exactly this notation). The function receives a single attribute - the RSSLoader object that just finished loading and displaying the rss feed. Here is an example

    function onRssLoad( hRssLoader )

     var sDivId = hRssLoader.hDiv.id

Changes [18.02.2005]: MAJOR CHANGES
  • Added new atttribute:
    rssauto="true|false"
    set this to false if you do not want the block to start loading when the page loads. default is true
  • Added a timeout error handler. The time after which the handler gets called is controlled by this constant:
    cRSSParser.CN_TIMEOUT = 5000
    Default is 5000 (milliseconds)
    After the time elapses an error message is written to the block
  • Added new examples - you can have multiple feeds loading in a single rss feed block. (see below)
  • In connection with the above described example fixed a bug that appeared in internet explorer. Obviously one should set the onreadystatechange event handler after open() and before send() is called (here I mean methods of the xmlhttp objects).
Changes [08.04.2005]:
  • Changed the php script that acts as a proxy so now it can take a url of an ordinary page ( news.bbc.co.uk) and search in it for the rss feed and then load it. In other words convinience for the lazy of us :)



Requirements:
morss.js

Tested under:
IE 6.0, Mozilla /NS 6,7/, Firefox


Examples:
select a feed to be loaded
 
Do not try to load slashdot.org but rather access directly the file http://slashdot.org/index.rss because slashdot is returning a page which has urls striped of the http: part. So you get something like //slashdot.org/index.rss as a link to the rss feed. This is an exception so I did not bother to write special code to it
Files: