Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- From: "Niran" <public.niran@xxxxxxxxx>
- To: <programmingblind@xxxxxxxxxxxxx>
- Date: Sat, 28 Jun 2008 18:52:09 +0530
Instead of using document.write to output the html within the javascript file,
try to pass the ID of the div to the script and use some thing like
document.getElementById( 'id').innerHTML = "html";
This may work, as some local tests which I did showed that document.write does
not work when executed within dynamicly loaded script. and directly setting the
html of a specific div does work.
Try it out, and, let me know the results.
niran
----- Original Message -----
From: Bryan Garaventa
To: programmingblind@xxxxxxxxxxxxx
Sent: Saturday, June 28, 2008 5:50 AM
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%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
http://www.freelists.org/list/programmingblind
- Follow-Ups:
- Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- From: Bryan Garaventa
- References:
- jfw question
- From: Juan Hernandez
- Re: jfw question
- From: Octavian Rasnita
- perl - example needed
- From: Lamar Upshaw
- Re: perl - example needed
- From: Octavian Rasnita
- perl - cookies
- From: Lamar Upshaw
- Re: perl - cookies
- From: Octavian Rasnita
- Re: perl - cookies
- From: Lamar Upshaw
- Re: perl - cookies
- From: Octavian Rasnita
- cookies - https://
- From: Lamar Upshaw
- JavaScript Trouble, dynamic script not running JS for news feeds?
- From: Bryan Garaventa
Other related posts:
- » JavaScript Trouble, dynamic script not running JS for news feeds?
- » RE: JavaScript Trouble, dynamic script not running JS for news feeds?
- » Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- » RE: JavaScript Trouble, dynamic script not running JS for news feeds?
- » Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- » Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- » Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- Re: JavaScript Trouble, dynamic script not running JS for news feeds?
- From: Bryan Garaventa
- jfw question
- From: Juan Hernandez
- Re: jfw question
- From: Octavian Rasnita
- perl - example needed
- From: Lamar Upshaw
- Re: perl - example needed
- From: Octavian Rasnita
- perl - cookies
- From: Lamar Upshaw
- Re: perl - cookies
- From: Octavian Rasnita
- Re: perl - cookies
- From: Lamar Upshaw
- Re: perl - cookies
- From: Octavian Rasnita
- cookies - https://
- From: Lamar Upshaw
- JavaScript Trouble, dynamic script not running JS for news feeds?
- From: Bryan Garaventa