dynamicaly parsing a RSS feed to a newsticker applet.

S

Shogan

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top