JavaScript Trouble, dynamic script not running JS for news feeds?

  • From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 27 Jun 2008 17:20:06 -0700

Hi, I've been trying to get this thing working for a few days now, but I think I'm missing something.


I'm trying to work out a better and more dynamic method for loading the news feeds at http://gutterstar.net/news.php All of these news feeds are being loaded using the script at http://gutterstar.net/rss , which is rendered within a standard <script type="text/javascript" src="http://rssScriptGenURLOutput.php?stuffVariables";></script>

My idea is that, if I could dynamically load each RSS feed when a link is clicked, the load delay would be much less, and no page refresh would occur to disrupt navigation.

So I wrote the test page at http://gutterstar.net/news_test.htm Which, by all that I've read, should work, except that it doesn't...

I was able to get the code below to work briefly when the page first loaded, but nothing after that. Now it doesn't even work when the page loads for some reason. The dynamic aspect just isn't working at all. I've saved out the live DOM to see if it's adding the correct script to the right Div, and everything appears to be updating correctly in the DOM, but I can't see anything on the page itself, which is really weird. Anyone know what I'm doing wrong?

<html>

<head>

<script type="text/javascript">

/*<![CDATA[*/

var n1 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fmain.rss&crss=11940&MAXITEMS=10&HeaderText=Top+Stories&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n2 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fworld.rss&crss=11942&MAXITEMS=10&HeaderText=World+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n3 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fnational.rss&crss=11943&MAXITEMS=10&HeaderText=U.S.+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n4 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Ffeeds.cbsnews.com%2FCBSNewsUTTM&crss=11944&MAXITEMS=10&HeaderText=Up+To+The+Minute%A0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n5 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fbusiness.rss&crss=11945&MAXITEMS=10&HeaderText=Business+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n6 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fscitech.rss&crss=11946&MAXITEMS=10&HeaderText=Sci-Tech%A0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n7 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2Fpolitics.rss&crss=11948&MAXITEMS=10&HeaderText=Politics%A0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n8 = 'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fwww.cbsnews.com%2Ffeeds%2Frss%2F501370.rss&crss=11951&MAXITEMS=10&HeaderText=Strange+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&SectionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

function getRSSFeed(url, id) {

var e = document.getElementById(id);

if (e.innerHTML == '') {

var newScript = document.createElement('script');

newScript.type = 'text/javascript';

newScript.src = url;

e.appendChild(newScript);

}

if (e.style.display == 'none') {

e.style.display = 'block';

e.style.visibility = 'visible';

}

}

/*]]>*/

</script>

</head>

<body>

<div>

<a onclick="getRSSFeed(n1, 'n1d');return false;" href="#">Top Stories</a>|

<a onclick="getRSSFeed(n2, 'n2d');return false;" href="#">World News</a>|

<a onclick="getRSSFeed(n3, 'n3d');return false;" href="#">U.S. News</a>|

<a onclick="getRSSFeed(n4, 'n4d');return false;" href="#">Up To The Minute News</a>|

<a onclick="getRSSFeed(n5, 'n5d');return false;" href="#">Business News</a>|

<a onclick="getRSSFeed(n6, 'n6d');return false;" href="#">Sci-Tech News</a>|

<a onclick="getRSSFeed(n7, 'n7d');return false;" href="#">Politics News</a>|

<a onclick="getRSSFeed(n8, 'n8d');return false;" href="#">Strange News</a>

</div>

<div style="display:none;visibility:hidden;" id="n1d"></div>

<div style="display:none;visibility:hidden;" id="n2d"></div>

<div style="display:none;visibility:hidden;" id="n3d"></div>

<div style="display:none;visibility:hidden;" id="n4d"></div>

<div style="display:none;visibility:hidden;" id="n5d"></div>

<div style="display:none;visibility:hidden;" id="n6d"></div>

<div style="display:none;visibility:hidden;" id="n7d"></div>

<div style="display:none;visibility:hidden;" id="n8d"></div>

<script type="text/javascript">

getRSSFeed(n8, 'n8d');

</script>

</body></html>

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: