dynamicaly parsing a RSS feed to a newsticker applet.

Discussion in 'Javascript' started by Shogan, Jul 22, 2005.

  1. Shogan

    Shogan Guest

    I stumbled on this capability of javascript by accident.
    here's the applet I'm using:
    http://javaboutique.internet.com/AdvNewsticker/

    feel free to modify to code to apply this capability to any other
    method of display you feel like.

    and here's the code to do the parsing for the applet.

    <HEAD>
    <script type="text/javascript">
    function RSStoapplet(){

    var iMax = 20

    var rssDoc = new ActiveXObject("Microsoft.XMLDOM")
    rssDoc.async = false
    rssDoc.load("YourRSSFeed.xml")

    var headNode = rssDoc.selectNodes("/rss/channel")
    var itemNodes = rssDoc.selectNodes("/rss/channel/item")

    if(itemNodes.length<iMax){
    iMax = itemNodes.length
    }

    document.writeln("<p><center><font color=\"FFFF00\">" +
    headNode.item(0).getElementsByTagName("title").item(0).text +
    "</font></center></p>");
    document.writeln("<applet
    code=\"http://javaboutique.internet.com/AdvNewsticker/advnewsticker.class\"
    width=\"100%\" height=\"27\">");
    document.writeln("<param name=\"regcode\" value=\"\">");
    document.writeln("<param name=\"info\" value=\"Applet by Gokhan
    Dagli,www.appletcollection.com\">");
    document.writeln("<param name=\"input_text\"
    value=\"from_parameters\">");
    document.writeln("<param name=\"text_file\" value=\"\">");
    document.writeln("<param name=\"bgcolor\" value=\"000000\">");
    document.writeln("<param name=\"text_color\" value=\"FFFF00\">");
    document.writeln("<param name=\"highlight_text_color\"
    value=\"4876FF\">");
    document.writeln("<param name=\"font_type\" value=\"Arial\">");
    document.writeln("<param name=\"font_size\" value=\"14\">");
    document.writeln("<param name=\"font_style\" value=\"0\">");
    document.writeln("<param name=\"underline\" value=\"no\">");
    document.writeln("<param name=\"border_thickness\" value=\"1\">");
    document.writeln("<param name=\"border_color\" value=\"000000\">");
    document.writeln("<param name=\"highlight_border_color\"
    value=\"000000\">");
    document.writeln("<param name=\"text_align\" value=\"center\">");
    document.writeln("<param name=\"xoffset\" value=\"5\">");
    document.writeln("<param name=\"yoffset\" value=\"0\">");
    document.writeln("<param name=\"pause_time\" value=\"5000\">");
    document.writeln("<param name=\"hscroll_delay\" value=\"8\">");
    document.writeln("<param name=\"vscroll_delay\" value=\"30\">");
    document.writeln("<param name=\"typewriter_delay\" value=\"30\">");
    document.writeln("<param name=\"fade_delay\" value=\"100\">");
    document.writeln("<param name=\"effects\" value=\"custom\">");
    document.writeln("<param name=\"custom_in_effects\" value=\"1\">");
    document.writeln("<param name=\"custom_out_effects\" value=\"1\">");
    for(i=0;i<iMax;i++){
    document.writeln("<param name=\"text" + (i+1) + "\" value=\"" +
    itemNodes.item(i).getElementsByTagName("title").item(0).text + "\">");
    document.writeln("<param name=\"link" + (i+1) + "\" value=\"" +
    itemNodes.item(i).getElementsByTagName("link").item(0).text + "\">");
    document.writeln("<param name=\"target_frame1\" value=\"_blank\">");
    }
    document.writeln("</applet>");
    document.writeln("<FORM>");
    document.writeln("<div align=\"center\">");
    document.writeln("<INPUT TYPE=\"button\" class=\"buttonStyle\"
    onClick=\"history.go(0)\" VALUE=\"Reload Page\">");
    document.writeln("</div>");
    document.writeln("</FORM>");
    document.writeln("</body></html>");
    }
    </script>
    </HEAD>
    <body bgcolor=000000 onload="setTimeout('history.go(0)',300000);">
    <script type="text/javascript">
    RSStoapplet();
    </script>
    </body>


    I am having javascript dynamicaly create the html code for the applet
    call to include the text into the applet.
    Note also that I am refreshing the page every 5 minutes so the news
    doesn't get stale.

    the code to pull the rss feed and manipulate it came from:
    http://www.howtodothings.com/ViewArticle.aspx?Article=74

    this also works but I think mine looks prettier. (sorry if you don't
    like the colour scheme)

    have fun with this.

    Shogan
    Shogan, Jul 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    704
    SpaceGirl
    Feb 25, 2005
  2. Motta
    Replies:
    1
    Views:
    502
    Andy Dingley
    Jun 9, 2004
  3. Scott Gordo
    Replies:
    5
    Views:
    676
  4. Jonathan Groll
    Replies:
    1
    Views:
    248
    Kouhei Sutou
    Jun 27, 2009
  5. R.P.
    Replies:
    4
    Views:
    104
    Thomas 'PointedEars' Lahn
    Nov 17, 2008
Loading...

Share This Page