473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Reloading div content, after its innerHTML changes

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.
Is there a way to this? May be by adding an event listener? I thought
things like using setInterval, getting the div as a node duplicating
it, modifying it and then replacing it but didn't try them since I
believe same problem will persist.

The overall thing seems something like this:

<SELECT onChange="changeFeed(this.value)>
....
<div id=rssFeed>
....
</div>

<javascript>
function changeFeed(feedID) {
.....
var str = "<script language=Javascript ";
str += "src=http://...rsstohtml.php?rssfeed=somefeed.xml></script>"
!! where somefeed.xml is generated based on feedID and in fact a full
URL
elem = document.getElementById('rssFeed');
elem.innerHTL = str;
....
}
</javascript>

I just wrote these over the top of my head to paint a picture, so
ignore typos, syntax errors etc.

I'd appreciate if you can suggest some way to overcome this.

I have a workaround like having div's for each feed, loading their
content initially but not displaying them (CSS, style.display=none)
and only display when user selects them. But I don't like it and if I
wanted to enable choosing among many feeds it becomes costly (both for
the initial loading, call the external script N times and the writing
the HTML, very crowded).

Another solution may be updating a cookie with the selected feedID,
reloading the page, while loading the page checking the cookie to
display the selected feed but I don't like the "reload page" part.

I should also mention that I can only run client side javascript on
this page, no CGI, PHP etc.

Thanks.

iZzeT
Jul 23 '05 #1
1 14352


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/
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sam | last post by:
I am constructing a company intranet. On the intranet I made an overview-page which displays the availability of equipment. The information comes out of a database, and is retrieved by php-script....
2
by: Charlie | last post by:
Hey all: I have a very simple script that changes an image when the user 'OnMouseOver's it. it works without a problem, but the progress bar at the bottom of the browser window reappears with...
2
by: rpesq | last post by:
Hi, I Need help changing the content of a DIV. I sincerely researched the issue and have not found a solution except to scrap the idea and stick with the iframe code that I had been using. My...
9
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
4
by: R | last post by:
Hi All, I have a problem with reloading JS. I have a DIV where I placed JS code displaying random tricks & tips from other site. at the beggining I had it this way: <div id="tips">
1
by: praveenmmohanan | last post by:
Hi..., We have a pretty huge form where the user/support spends more than 6 minutes. Now, behind the scenes, I wanted to capture the outerHTML data & send it to a different URL to save it in...
4
by: Robson Siqueira | last post by:
Folks, I am facing a problem. I am trying to manipulate the HTML data (thru the Document and DocumentText properties) of the WebBrowser object (System.Windows.Forms). The problem is that the...
0
by: Romulo NF | last post by:
Greetings again everyone Recently i´ve been asked to develop a script to allow filtering in the content of the table, with dinamic options based on the own content. Example: a table with the name of...
1
by: red | last post by:
I have a page with a div which is filled with content from a PHP script via javascript and innerhtml. Sometimes, depending on the results of the PHP script, I want to to reload the entire page,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.