473,387 Members | 1,603 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,387 software developers and data experts.

Setting Div Value (nodes problem)

5
Ok so I have researched this problem and am confused. What I want do is have a caption in a <div> under a picture be changable. So I have this:

Expand|Select|Wrap|Line Numbers
  1. <div id="Caption" style="color: rgb(51,51,102); font-family: Verdana; font-size: 90%; text-align: center"></div>
  2. <script type="text/javascript"> //Set Caption- use abs to avoid array error with three digit variable
  3. document.getElementById("Caption").childNodes[0].nodeValue = Captions[Math.abs(i)];
  4. </script>
But it only works in FF if I put a space in the original <div> and it doesn't work in IE at all. Don't get it. What do I need to do?
The full page is here.

Thanks for any help.
Apr 17 '07 #1
2 7583
Hi,
Try that

<script type="text/javascript"> //Set Caption- use abs to avoid array error with three digit variable
if (document.getElementById("Caption").firstChild) document.getElementById("Caption").firstChild.node Value = Captions[Math.abs(i)];
else document.getElementById("Caption").appendChild(doc ument.createTextNode(Captions[Math.abs(i)]));
</script>


And remove that white space from div, leave it "empty".
Additionaly, please remember that FF treats all new-line signs as nodes so if have for instance div:
<div class="example">
<div></div>
<div></div>
</div>

that div (example) has 5 childNodes in FF in IE it has 2.
Apr 17 '07 #2
ace214
5
Ok, that worked, thanks for the help. Although, I think I'm just gonna make the div contain one letter- it's easier than making it process the if. Thanks again.
Apr 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Andy C | last post by:
I am new to python, so please bear with me if I am making some conceptual error. Basically I want to create a graph with an adjacency list representation, but I don't want any of the adjacency...
4
by: elora_c | last post by:
I'm trying to write XSLT that will filter out an XML based on an attribute's value. XML looks like: <postings> <channel name="A"> <posting Connected="True" name="Posting1" /> <posting...
1
by: relaxedrob | last post by:
Howdy All! I am really stuck with this one - I want to completely create a table within JavaScript and insert it into the document, with onMouseOut and onMouseOver handlers in the table rows. ...
1
by: Michael Søndergaard | last post by:
I am trying to read all orders element, which have the attribute Phase="Reorganize". I am using the following code on the xml document. private void LoadPhase (XmlDocument Doc, TreeNode Parent,...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
2
by: Urs Vogel | last post by:
Hi When using XmlDocument, I can create nodes and attributes as I like. What I didn't achieve is changing the Value of a node (created with createElement), it claims that it's the wrong node...
0
by: johkar | last post by:
I have a vendor application that is returning nodes as shown below. The String nodes actually equate to something more user friendly like Employee and Customer. Is there any way to provide a...
7
by: ravi | last post by:
Hi, I am a newbie to javascript. Iam working on a page that has two radio buttons and a tree. I do not have my tree nodes to be selectable. Iam working on Firefox. I have the firebug...
2
by: deepika patra | last post by:
hi all, let me explain u my problem in detail.i m trying to develop an application in c#.net. i have to show a form in wich i hav to take a check box & a quit menu.wen i press the quit...
0
by: Andy | last post by:
Hello all, I have a user getting an error 438, object doesn't support this prop. or method, when I run code to setup the treeview control. I'm using the MSCOMCTRL.OCX, file version: 6.01.9545....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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,...
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...

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.