abcd_68@yahoo.co.uk wrote:
[...][color=blue]
> Problem is the following. I've got a fairly complex (for my abilities
> at least) page with nested tables. Think of it as a small spreadsheet,
> in which I have to perform computations (in Javascript of course) on a
> per row basis and compute the grand totals in the bottom line. All the
> rows are contained in a big form the will eventually be submitted. Upon
> page loading I need to fill up arrays of references to the various
> input elements so as to be able to quickly recompute totals in the
> bottom line when the user changes some value. I do so by exploiting the
> DOM, using constructs such as document.getElementById(), childNodes,
> parent, etc.
>
> So far so good and, as a matter of the fact, everything works perfectly
> under firefox 1.5. Not so under IE 6 (on the same machine, running
> WinXP SP2). Problem lies in the array initialisation. At first I used a
> simple onload() function which works just fine under FF. This was not
> working on IE so I set up an init() function (changed names just in
> case, but the automatic association between event name and function
> name does not seem to work under IE anyway) and tried all of the[/color]
There is nothing that says a function called 'init' will be called by
window.onload simply because it exists and is called 'init'. You have
to assign either a reference or function to the window onload property,
the name is irrelevant (provided it meets the criteria for JavaScript
function names).
[color=blue]
> following (one at a time of course):
> <body onload=init>[/color]
---------------^^^^^
Probably just a posting typo:
<body onload="init();">
[color=blue]
> window.onload = function () {init();}
> window.onload = init
> window.addEventListener('load', init, true|false)
> window.attachEvent('onload', init)
>
> Apart from addEventListener which IE frowns upon (I knew it wouldn't
> work but I tried out of desperation), all the others "work" i.e., the
> init function is actually called (my debugging alerts pop up). Problem
> is, in all cases (under IE) said function fails to properly initialise
> the arrays, issuing errors such as "childNodes is null or not an
> object" and the like.
>
> In my (possibly naive) interpretation, the root of the problem is that
> when init() is called the DOM hasn't been properly initialised yet. I[/color]
Or you are doing something that prevents IE from seeing the childNodes
but not Firefox. A recent issue was that using innerHTML on the title
element caused similar behaviour (but that may not be your problem).
AFAIK, onload works as expected in IE.
[color=blue]
> try to retrieve elements by id but those elements are not completely
> formed e.g., they have no children. However, this is against all that I
> read about onload being fired *after* everything has been properly set
> up. And again, everything is working just fine under FF so the object
> references I use do make sense.
>
> I'm stuck... Can you help?[/color]
Post a URL or a minimal example that displays the behaviour.
--
Rob