473,664 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

children["id"].innerText - does not work with netscape but with explorer

I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay (myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement. children["calDateTex t"].innerText);
6 /*
7 ...
8 */
9 }
10 <!-- ... -->
11 <td id=calCell onclick='fSetSe lectedDay(this) '>
12 <font id='calDateText ' onclick='fSetSe lectedDay(this) '>
13 <script> myMonth[w][d] </script>
14 </font>
15 </td>
16 <!-- ... -->
I need some support for this.
Thank you very much.
Jul 23 '05 #1
13 3788
Julia Peterwitz wrote:
I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay (myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement. children["calDateTex t"].innerText);


..innerText is IE only, and as such is not going to work in NS. use
innerHTML instead.

eval is not needed there:

var elementText =
document.getEle mentById(myElem ent).children(' calDateText').i nnerHTML;

the [ ] are also an IE-ism.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
On Wed, 05 May 2004 06:41:28 -0400, Randy Webb <hi************ @aol.com>
wrote:
Julia Peterwitz wrote:
I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
1 fSetSelectedDay (myElement){
2 /*
3 ...
4 */
5 var elementText = eval(myElement. children["calDateTex t"].innerText);
.innerText is IE only, and as such is not going to work in NS. use
innerHTML instead.

eval is not needed there:


Agreed, however...
var elementText =
document.getEle mentById(myElem ent).children(' calDateText').i nnerHTML;


....there are two problems with this line:

1) If you look at the OP's HTML, you'll see that myElement is a
reference to the element, not an id.
2) The children property is
a) a collection, so the brackets were correct,
b) also a Microsoft-ism.

Perhaps

var elementText = myElement.child Nodes[ 'calDateText' ].innerHTML;

would be better (preferably with feature detection)?

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #3
myElement.child Nodes[ 'calDateText' ].innerHTML;
is also not working
(it neither works in explorer nor in netscape)

any other proposals for netscape??

solution for explorer again:
myElement.child ren["calDateTex t"].innerText;

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
On 05 May 2004 16:37:14 GMT, julia peterwitz <pi***@gmx.de > wrote:
myElement.child Nodes[ 'calDateText' ].innerHTML;
is also not working
(it neither works in explorer nor in netscape)

any other proposals for netscape??


Oops. I assumed that childNodes was a standard collection that could be
indexed by name/id as well as ordinal. However, I just thought that
'calDateText' is an id, so why don't you just use

document.getEle mentById( 'calDateText' ).innerHTML

?

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #5
pi***@gmx.de (Julia Peterwitz) writes:
I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
You don't say which Netscape. If it's Netscape 4, your options are
very limited. If it's Netscape 6+, i.e., based on Mozilla, then
you can pretty much fly :) I'll assume Netscape 6+.
5 var elementText = eval(myElement. children["calDateTex t"].innerText);
I see three problems:
- innerText is IE only.
- children is IE only.
- eval is evil.

There are different options, depending on how standards compliant you
want to be. I'll go for full compliance with the DOM specification
(i.e., avoiding innerHTML).

A version that collects the string content of the calcDateText element
(not recursively, so don't put the text to find inside tags).
---
var span = document.getEle mentById("calcD ateText");
var elementText = "";
for(var chld = span.firstChild ; chld; chdl=chld.nextS ibling) {
if (chld.nodeType == 3) { // text node
elementText += chld.nodeValue;
}
}
---
Or, change the first line to:
---
var span = myElement.getEl ementsByTagName ("span")[0];
---
(Notice that I use "span" instead of "font" as commented later)
11 <td id=calCell onclick='fSetSe lectedDay(this) '>
12 <font id='calDateText ' onclick='fSetSe lectedDay(this) '>
The font tag is deprecated and you are not using any of its specific
attributes anyway. Change it to a <span> instead, that is just what
you need: a meaningless wrapper.
13 <script> myMonth[w][d] </script>
The type attribute is required on script tags, so:
---
<script type="text/javascript">
---
Do you mean to document.write the value?
---
document.write( myMonth[w][d]));
---
Where are "w" and "d" calculated? (Meaning Week and Day?)
14 </font>

</span>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote in message news:<hd******* ***@hotpop.com> ...
pi***@gmx.de (Julia Peterwitz) writes:
I have a function that works with explorer but not with netscape.
The problem is the function at line 5.
You don't say which Netscape. If it's Netscape 4, your options are
very limited. If it's Netscape 6+, i.e., based on Mozilla, then
you can pretty much fly :) I'll assume Netscape 6+.


yes, I thought about netscape 6+
5 var elementText = eval(myElement. children["calDateTex t"].innerText);
I see three problems:
- innerText is IE only.
- children is IE only.
- eval is evil.

There are different options, depending on how standards compliant you
want to be. I'll go for full compliance with the DOM specification
(i.e., avoiding innerHTML).

A version that collects the string content of the calcDateText element
(not recursively, so don't put the text to find inside tags).
---
var font= myElement.getEl ementsByTagName ("font");
var elementText = "";


until here it works.
but the following doesn't start.
and I don't know why.
but there is no error message.
for(var chld = font.firstChild ; chld; chdl=chld.nextS ibling) {
if (chld.nodeType == 3) { // text node
elementText += chld.nodeValue;
}
}
---
11 <td id=calCell onclick='fSetSe lectedDay(this) '>
12 <font id='calDateText ' onclick='fSetSe lectedDay(this) '>
The font tag is deprecated and you are not using any of its specific
attributes anyway. Change it to a <span> instead, that is just what
you need: a meaningless wrapper.


I removed the irrelevant attributes.
so I will use <font> further on.
13 <script> myMonth[w][d] </script>
The type attribute is required on script tags, so:
---
<script type="text/javascript">
---
Do you mean to document.write the value?
---
document.write( myMonth[w][d]));


sorry I forgot to put the document.write around

13 <script> document.write( myMonth[w][d]); </script>

this function notes the days of the months, but this is irrelevant for
the problem. isn't it?
---
Where are "w" and "d" calculated? (Meaning Week and Day?)
14 </font>

</span>

/L

Jul 23 '05 #7
pi***@gmx.de (Julia Peterwitz) writes:
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote in message news:<hd******* ***@hotpop.com> ...
var font= myElement.getEl ementsByTagName ("font");
var elementText = "";


until here it works.
but the following doesn't start.
and I don't know why.
but there is no error message.
for(var chld = font.firstChild ; chld; chdl=chld.nextS ibling) {


Damn! :(
That would be the typo: ^^^^ shoud be chld.

That would mean that the loop goes on forever ... doing nothing.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #8
/*
....
*/

alert("1");
var font = myElement.getEl ementsByTagName ("font");
alert("2");
var elementText = "";
alert("3");
for(var chld = font.firstChild ; chld; chld=chld.nextS ibling) {
alert("4");
if (chld.nodeType == 3) { // text node
elementText += chld.nodeValue;
}

/*
....
*/

when I start this I'll get the alert's 1,2,3 but the alert 4 doesn't start.
so I think there is something wrong.
but I don't know what.
Jul 23 '05 #9
Michael Winter <M.******@bluey onder.co.invali d> wrote in message news:<op******* *******@news-text.blueyonder .co.uk>...
On 05 May 2004 16:37:14 GMT, julia peterwitz <pi***@gmx.de > wrote:
myElement.child Nodes[ 'calDateText' ].innerHTML;
is also not working
(it neither works in explorer nor in netscape)

any other proposals for netscape??


Oops. I assumed that childNodes was a standard collection that could be
indexed by name/id as well as ordinal. However, I just thought that
'calDateText' is an id, so why don't you just use

document.getEle mentById( 'calDateText' ).innerHTML

?

Mike

elementText = document.getEle mentById('calDa teText').innerH TML;
alert(elementTe xt);

good idea, but elementText is "".
do you know why?
Jul 23 '05 #10

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

Similar topics

4
3204
by: kaeli | last post by:
All, I've been unable to find out if javascript supports for (var e in obj) type of looping syntax. Does it? If so, is this for DOM browsers only? TIA! --
0
1235
by: Bruce | last post by:
I have three tables in SQL serve tblareas (w/autoincrement ID tblprograms (w/autoincrement ID tblphases (w/autoincrement ID I've build cascading relation from tblareas <one-many> tblprograms <one-many> tblphase Both relations are one to many left to right I've created a DataSet with all three tables and built relations to mimic the datasourc
4
1978
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent. The path to each node is stored in the column "Path" and is of the form "\000001\000002\000003\" etc. The latter enabling me to fetch subtrees using the "LIKE" predicate. I also have created the relation "ID" <-> "ID_Parent, effectively the...
7
5843
by: GfxGuy | last post by:
I've seen this problem posted a million times, but I've read through all of them and can't figure out what I'm doing wrong. Simple example (this is the whole file, no editing): ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
19
6766
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has one, and only one parent. The depth should not exceed 6 or 7 levels. The initial import will have about 6 million leaves, and 3 million branches. I would expect the leaves to grow significantly, in number easily tripling. However, the branches will...
1
10455
by: John Beard | last post by:
I downloaded the attached code from MS. It flips on the "User Cannot Change Password" on a user in AD and works great from a console or windows app, but when put into an ASP.NET app I get a "The security ID structure is invalid." error when trying to assign the new security descriptor. I am running in Windows Authentication mode with IIS set to Integrated security on an XP box. Does anyone have a work around for this? Thanks in...
3
2809
by: ivanov.alexei | last post by:
It's my first post and first DB application. Environment: MFC DAO, MS Access database I want to have several tables which have links to the fields to other tables. The following example explains the basic idea. CREATE TABLE husbands ( id COUNTER, name TEXT, age LONG,
9
4835
by: Tristán White | last post by:
Hi I am very new to PHP - actually, this is my second day at it, as I've only recently started a new job last week. We're a charity. I have a "No input file selected" problem. A Google search has shown me that this is a common problem, but I have tried to follow all the various instructions but none of them make any difference. First of all... Some background on the page it links from.....
0
8348
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
8863
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
8779
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
8549
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,...
1
6187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1761
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.