473,503 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mozilla, written html and getElementById

Mozilla (1.4 win2k) doesn't like this

document.write ('<TABLE ID="abc"><TR><TD></TD></TR></TABLE>')
table = document.getElementById ('abc')
alert (table.rows.length)

I see in JS Console, Error: table has no properties

The same message that would appear if I tried to get real non-existant id
table = document.getElementById ('abc-doesnotexist')
alert (table.rows.length)

Any work arounds ( Not in a position to place my own null table in source
HTML:( ) ?
Should I skip making 1.4 happy and wait for Moz 1.5+ ?

--
Richard A. DeVenezia
Jul 20 '05 #1
4 4451
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
Mozilla (1.4 win2k) doesn't like this

document.write ('<TABLE ID="abc"><TR><TD></TD></TR></TABLE>')
table = document.getElementById ('abc')
alert (table.rows.length)

I see in JS Console, Error: table has no properties

This happens in a js that is being loaded in the <HEAD> tag
--
Richard A. DeVenezia

Jul 20 '05 #2
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
Mozilla (1.4 win2k) doesn't like this

document.write ('<TABLE ID="abc"><TR><TD></TD></TR></TABLE>')
table = document.getElementById ('abc')
alert (table.rows.length)

I see in JS Console, Error: table has no properties


This happens in a js that is being loaded in the <HEAD> tag


A table element within the HEAD of a document would be invalid so if the
function is called within the head it is unrealistic to expect it to
work. But I would be expect timing problems with this code anyway as
the browser may not get a chance to fully set up the objects created
with the document.write statement before it is references. (Indeed I
recall that at least one browser delays document.write output until the
completion of the current script block)

It would probably be safer to use DOM node insertion methods to create
and insert a valid table structure. Then you would have a reference to
it prior to inserting it and would not have to use getElementById at all
(or give the table an ID). Alternatively you would probably have to
split the code with the document.write inserting the HTML inline and
another "init" function being called onload (or with a timeout).

Richard.
Jul 20 '05 #3
"Richard A. DeVenezia" <ra******@ix.netcom.com> writes:
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
Mozilla (1.4 win2k) doesn't like this

document.write ('<TABLE ID="abc"><TR><TD></TD></TR></TABLE>')
table = document.getElementById ('abc')
alert (table.rows.length)

I see in JS Console, Error: table has no properties

My guess:
You use document.write to insert context in the input stream after
the current script element. It is not parsed until after the script
tag ends.

Try ending the script tag after the document.write and start a new
script tag with the rest of the code.
This happens in a js that is being loaded in the <HEAD> tag


So, you are writing tables into the head tag? That means that
the head tag must have stopped, so the browser automatically ends
the head tag and starts the body tag.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Il Wed, 10 Sep 2003 11:32:52 +0200, Lasse Reichstein Nielsen ha scritto:
"Richard A. DeVenezia" <ra******@ix.netcom.com> writes:
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
> Mozilla (1.4 win2k) doesn't like this
.... So, you are writing tables into the head tag? That means that the head
tag must have stopped, so the browser automatically ends the head tag
and starts the body tag.

/L


Maybe he meant that the script tag containing that portion of code is
inside the head and not in the body, I'm just supposing.

gp
Jul 20 '05 #5

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

Similar topics

12
5899
by: Justin Koivisto | last post by:
I am having a problem with Internet Explorer and javascript on a WYSIWYG editor I am creating. It all works in Mozilla, but IE returns flase for queryCommandEnabled('forecol'). JS isn't my strong...
6
6823
by: David List | last post by:
I'm having a problem using different properties of the document object in the example javascripts in my textbook with browsers that identify themselves as using the Mozilla engine. One example of...
1
2471
by: Macamba | last post by:
Hi all, I am currently developing a website for a voluntary organisation. It is my first step in website development. The dynamic menu I developed has some bugs, which I addressed in another...
3
1641
by: Jim Ley | last post by:
Hi, It seems the mozilla guys have chosen another (almost certainly poor choice in my initial thoughts) of having document.all evaluate to false, but document.all catch the chicken event - also...
8
2906
by: Nicolás Lichtmaier | last post by:
Hi, some time ago I've written an article about this issue. It explain some differences in Explorer's and Mozilla's JavaScript/DOM. It has recently changed its URL, This is the new one: ...
1
4935
by: Ryan Stewart | last post by:
If you don't want to read this post because of its length, I understand. I've spent two and a half days on this problem and have a good deal of information to relate. And this is kind of a long...
6
2814
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
0
3054
by: javaguy | last post by:
I have a table I hide show/hide through a pair of divs. The show/hide part works fine in both Mozilla and MSIE. When switching between the hide and show versions the Mozilla browser keeps them in...
2
2309
by: Robert Wagner | last post by:
I've created a page using VS.NET and page validator controls. The client side validation works fine on IE, but does not even activate under "alternate" browsers like Mozilla, Opera, etc. Why is...
0
7203
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
7087
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...
0
7281
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,...
1
6993
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...
0
5579
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,...
1
5014
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...
0
4675
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...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1514
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 ...

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.