Izzet Pembeci wrote:
> I am trying to display some rss feeds in my homepage. To do that I am
> using an external script which returns smth like:
> document.writeln("<div ...>")
> document.writeln("Title of News 1") !! read from the feed
> ....
> document.writeln("</div>")
>
> So displaying just one feed is a matter of adding the line:
> <script language=Javascript src="http....?rssfeed=somefeed.xml">
> </script>
>
> But I want to display more than one rss feed. I envision a design
> where I have a form/select referring to different rss feeds. When the
> reader selects a specific rss feed, a certain div's innerHTML changes
> to the script I mentioned above where somefeed.xml is the appropriate
> feed.
>
> The problem is when innerHTML changes, the external script is not
> called again.
Use an iframe, there you can change the location as needed e.g.
<iframe name="theFeed" src="showFeed?rssfeed=somefeed.xml">
<a href="showFeed?rssfeed=somefeed.xml">some feed</a>
</iframe>
You would need to change the result of showFeed to return HTML directly
and not script that document.writes HTML.
Then to change the displayed feed you use
<select name="feedSelect"
onchange="if (window.frames.theFeed) {
window.frames.theFeed.location.href =
'showFeed?rssFeed=' + escape(this.options[this.selectedIndex].value);
}">
<option value="somefeed.xml">some feed</option>
<option value="feed1.xml">feed 1</option>
...
</select>
If you really need to have that showFeed CGI return JavaScript then you
can document.write to the iframe e.g.
var iframeDoc = window.frames.theFeed.document;
iframeDoc.open();
iframeDoc.write('<script type="text/javascript"
src="showFeed?rssfeed=' + escape('somefeed.xml') + '"><\/script>');
iframeDoc.close();
--
Martin Honnen
http://JavaScript.FAQTs.com/