473,569 Members | 2,536 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><T D></TD></TR></TABLE>')
table = document.getEle mentById ('abc')
alert (table.rows.len gth)

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.getEle mentById ('abc-doesnotexist')
alert (table.rows.len gth)

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 4452
"Richard A. DeVenezia" <ra******@ix.ne tcom.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><T D></TD></TR></TABLE>')
table = document.getEle mentById ('abc')
alert (table.rows.len gth)

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.ne tcom.com> wrote in message
news:bj******** ****@ID-168040.news.uni-berlin.de...
"Richard A. DeVenezia" <ra******@ix.ne tcom.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><T D></TD></TR></TABLE>')
table = document.getEle mentById ('abc')
alert (table.rows.len gth)

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.ne tcom.com> writes:
"Richard A. DeVenezia" <ra******@ix.ne tcom.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><T D></TD></TR></TABLE>')
table = document.getEle mentById ('abc')
alert (table.rows.len gth)

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.ne tcom.com> writes:
"Richard A. DeVenezia" <ra******@ix.ne tcom.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
5908
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 suit, so I am turning to all you experts for help. What am I missing here? Other commands like formatblock, fontsize and fontname all work fine, so I...
6
6828
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 these problems is using document.layers. I have Google'd for examples of how to use the document object specifically with Mozilla, but I cannot find...
1
2477
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 post. In this post I want to ask you why my code behaves differently in IE, while it behaves like I expect in Mozilla and Opera. What I would like to...
3
1649
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 document.all.tags will work. It seems that the document.all not evaluating to true is to stop the really dumb object assumption scripts to fail...
8
2923
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: http://www.reloco.com.ar/mozilla/compat.html Bye! PS: I hope it's useful to someone. I would appreciate any comments and suggestions!
1
4949
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 shot, but I'm just hoping someone here has experienced a similar problem and has a better idea of what's going on than I do. First, I've tested this...
6
2822
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 and adjust to the newly added items like it does in iE. It just occured to me that i dont really have to use a span, and a html <hr> tag could do...
0
3061
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 small width, about 740 pixels. When switching between show/hide with MSIE the "show" table wants to display about 960 pixels. If I set the...
2
2313
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 this? I can't find any differences on the pages produced, and Mozilla should be able to handle everything IE can. How can I fix this?
0
7700
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...
0
7614
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...
1
7676
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...
0
6284
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...
1
5513
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...
0
5219
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...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
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...

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.