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

  • From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 28 Jun 2008 11:12:05 -0700

Still no go unfortunately. Here is some very simplified code, which I've
also commented thoroughly, so the flow should be much clearer. I'd
appreciate any help figuring this out, it's pretty frustrating, since it
should work. I did something similar which is the whole basis behind the
dynamic live chat application at http://gutterstar.net/dynamic_live_chat.php
, which is working correctly using the same principles. This is very
confusing.

New test URL: http://gutterstar.net/news_test2.htm

[New Code]

<html>

<head>

<script type="text/javascript">

/*<![CDATA[*/

// URL for the first news feed, which opens automatically when the page
loads

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=';

// URL for the second news feed, which opens when the link is clicked for
Strange News.

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 which dynamically creates the script, and adds it to the
necessary Div tag in the body.

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 tag that contains available news feed links. -->

<div>

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

</div>

<!-- Div tag that contains the first dynamically created RSS script when the
page first loads. -->

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

<!-- Div tag that contains the dynamically created RSS script when the
Strange News link is clicked. -->

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

<script type="text/javascript">

// Function call that opens the first RSS URL when the page loads.

getRSSFeed(n1, 'n1d');

</script>

</body></html>



----- Original Message ----- From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, June 28, 2008 5:41 AM
Subject: RE: JavaScript Trouble, dynamic script not running JS for news
feeds?




Well if you get your code down to one feed and its still not working send
it
again and I will have a go at it.

Ken

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Bryan
Garaventa
Sent: Saturday, June 28, 2008 1:43 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: JavaScript Trouble, dynamic script not running JS for news
feeds?

Thanks, I'll give it a go. I was able to get part of it working once
before,
I just wish I remembered how... Though even then, it only worked when the
page first loaded, which I guess sort of defeats the purpose.

----- Original Message -----
From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Friday, June 27, 2008 10:19 PM
Subject: RE: JavaScript Trouble, dynamic script not running JS for news
feeds?




Ok I was thinking of putting this up on my page and trying it but I
have a suggestion for debugging this.  Limit to testing it with one
rss feed and simplify the code as much as you can before you test it.
Once you get the more simple version working then you add the extra
feeds.

Ken


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Bryan
Garaventa
Sent: Friday, June 27, 2008 5:20 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: JavaScript Trouble, dynamic script not running JS for news
feeds?

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%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fmain.rss&crss=11940&MAXITEMS=10&HeaderText=Top
+Stori
es&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&Sect
ionHea
derClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman
&Secti
onTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS
&Secti
onRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=
newsfl ash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n2 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fworld.rss&crss=11942&MAXITEMS=10&HeaderText=Wo
rld+Ne
ws&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&Sect
ionHea
derClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Roman
&Secti
onTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+MS
&Secti
onRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindow=
newsfl ash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n3 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fnational.rss&crss=11943&MAXITEMS=10&HeaderText
=U.S.+
News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&Se
ctionH
eaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Rom
an&Sec
tionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans+
MS&Sec
tionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWindo
w=news flash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n4 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Ffe
eds.cb
snews.com%2FCBSNewsUTTM&crss=11944&MAXITEMS=10&HeaderText=Up+To+The+Mi
nute%A
0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&S
ection
HeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Ro
man&Se
ctionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans
+MS&Se
ctionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWind
ow=new sflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n5 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fbusiness.rss&crss=11945&MAXITEMS=10&HeaderText
=Busin
ess+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=lef
ess+t&Sect
ionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New
+Roman
&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+S
ans+MS
&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenW
indow= newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n6 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fscitech.rss&crss=11946&MAXITEMS=10&HeaderText=
Sci-Te
ch%A0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=le
ft&Sec
tionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+Ne
w+Roma
n&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+
Sans+M
S&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&Open
Window =newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n7 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2Fpolitics.rss&crss=11948&MAXITEMS=10&HeaderText
=Polit
ics%A0News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=l
eft&Se
ctionHeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+N
ew+Rom
an&SectionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic
+Sans+
MS&SectionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&Ope
nWindo w=newsflash&limit=&astr=&ReverseOrder=&license=&ApplyTo=';

var n8 =
'http://gutterstar.net/cgi-bin/apps/rss/js.php?RSSFILE=http%3A%2F%2Fww
w.cbsn
ews.com%2Ffeeds%2Frss%2F501370.rss&crss=11951&MAXITEMS=10&HeaderText=S
trange
+News&TitleText=&TableWidth=&TableHeight=&TableAlign=&TextAlign=left&S
+ection
HeaderClr=%236a5acd&SectionHeaderSize=2&SectionHeaderFont=Times+New+Ro
man&Se
ctionTitleClr=%23228b22&SectionTitleSize=2&SectionTitleFont=Comic+Sans
+MS&Se
ctionRowClr=%2300bfff&SectionRowSize=2&SectionRowFont=Verdana&OpenWind
ow=new sflash&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

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


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

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


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

Other related posts: