473,785 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.writel n("<div ...>")
document.writel n("Title of News 1") !! read from the feed
.....
document.writel n("</div>")

So displaying just one feed is a matter of adding the line:
<script language=Javasc ript src="http....?r ssfeed=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="chang eFeed(this.valu e)>
....
<div id=rssFeed>
....
</div>

<javascript>
function changeFeed(feed ID) {
.....
var str = "<script language=Javasc ript ";
str += "src=http://...rsstohtml.ph p?rssfeed=somef eed.xml></script>"
!! where somefeed.xml is generated based on feedID and in fact a full
URL
elem = document.getEle mentById('rssFe ed');
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=n one)
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 14369


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.writel n("<div ...>")
document.writel n("Title of News 1") !! read from the feed
....
document.writel n("</div>")

So displaying just one feed is a matter of adding the line:
<script language=Javasc ript src="http....?r ssfeed=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?r ssfeed=somefeed .xml">
<a href="showFeed? rssfeed=somefee d.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="feedSelec t"
onchange="if (window.frames. theFeed) {
window.frames.t heFeed.location .href =
'showFeed?rssFe ed=' + escape(this.opt ions[this.selectedIn dex].value);
}">
<option value="somefeed .xml">some feed</option>
<option value="feed1.xm l">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.t heFeed.document ;
iframeDoc.open( );
iframeDoc.write ('<script type="text/javascript"
src="showFeed?r ssfeed=' + escape('somefee d.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
6028
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. The users of the database should be able to change the status of the equipment. On the overview-page, I placed a button next to each piece of equipment. On pressing the button, a new window is opened, in which the user can input the changes....
2
1487
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 the change in image, and never finishes or goes away. When the page initially loads the progress bar completes and disappears. To change to image I am re-assigning it's .src
2
5260
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 purpose here is to avoid iframes. I know how to change the DIV content to other basic html statements, such as basic IMG's or Lists, but I want to put a Javascript into the DIV, and have not found a way to do it.
9
11189
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 DIV: <IFRAME id=myframe style="display:none" src="..." onload="ShowNews(this)"></IFRAME>
4
1752
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
1704
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 draft. Now there is no outerHTML in Firefox. secondly even innerHTML is different for IE & Firefox as in IE the updates I do to the text field are now visible in the innerHTML text but the changes are not visible when I run the javascript in...
4
13369
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 application enters in a loop state and my changes don't apply. Have somebody faced the same problem? Any solutions?
0
6105
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 some students and their respective numbers, and then you wanna show only studentes called "Joao", or students with number "5", or even only students called "joao" with number "5". The structure we are going to use is a basic html table, like: ...
1
1787
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, not just the div . However if I put a PHP redirect in the script, it just loads the entire page into the div.. This makes sense, since the I put the contents of the script page into the div, redirected or not. But how do I tell PHP to reload the...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.