Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > The final 'document.getElementById' fix - test on old browser needed ?

Reply
Thread Tools

The final 'document.getElementById' fix - test on old browser needed ?

 
 
Aaron Gray
Guest
Posts: n/a
 
      07-10-2008
Hi,

I know the 'document.getElementById()' issue is really over since every
browser since 1998 supports the W3C DOM standard, but I could not resist
this offering :-

if (!document.getElementById)
document.getElementById = function(id) { return document.all[id]; }

This should then provide a getElementById function if one does not already
exist.

Is anyone in a position to be able to test this code ?

You could go thurther and define :-

if (!document.getElementById)
if (document.all)
document.getElementById = function(id) { return
document.all[id]; }
else
document.getElementById = function(id) { return
document.layers[id]; }

Reference :-

http://www.jibbering.com/faq/faq_not...er_detect.html

Thanks,

Aaron


 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      07-11-2008
* Aaron Gray wrote in comp.lang.javascript:
>I know the 'document.getElementById()' issue is really over since every
>browser since 1998 supports the W3C DOM standard, but I could not resist
>this offering :-
>
> if (!document.getElementById)
> document.getElementById = function(id) { return document.all[id]; }
>
>This should then provide a getElementById function if one does not already
>exist.
>
>Is anyone in a position to be able to test this code ?


There's http://browsers.evolt.org and there are a number of free virtual
machine http://en.wikipedia.org/wiki/Categor...ation_software
products that you can use to set up old operating systems or just iso-
lated enviroments to run them.
--
Björn Höhrmann · private.php?do=newpm&u= · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
 
Reply With Quote
 
 
 
 
Svend Tofte
Guest
Posts: n/a
 
      07-11-2008
On Jul 11, 1:21*am, "Aaron Gray" <ang.use...@gmail.com> wrote:

> document.getElementById = function(id) { return document.layers[id]; }


NS4 Layers are more tricky then that. Layers that are nested will not
be exposed through the top level layers array. Example

document.layers['outerLayer'].document.layers['innerLayer'] (yes, it's
that messed up)

Regards,
Svend
 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-11-2008
Svend Tofte <> writes:

> On Jul 11, 1:21*am, "Aaron Gray" <ang.use...@gmail.com> wrote:
>
>> document.getElementById = function(id) { return document.layers[id]; }

>
> NS4 Layers are more tricky then that. Layers that are nested will not
> be exposed through the top level layers array. Example
>
> document.layers['outerLayer'].document.layers['innerLayer'] (yes, it's
> that messed up)


Also, layers is not the only collection worth checking. I would also
check document.images, document.links, etc., for each of the nested
documents, in order to better simulate document.getElementById.

Well, to be honest, I'd prefer to just drop support for Netscape 4.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
Aaron Gray
Guest
Posts: n/a
 
      07-11-2008
"Lasse Reichstein Nielsen" <> wrote in message
news:...
> Svend Tofte <> writes:
>
>> On Jul 11, 1:21 am, "Aaron Gray" <ang.use...@gmail.com> wrote:
>>
>>> document.getElementById = function(id) { return document.layers[id]; }

>>
>> NS4 Layers are more tricky then that. Layers that are nested will not
>> be exposed through the top level layers array. Example
>>
>> document.layers['outerLayer'].document.layers['innerLayer'] (yes, it's
>> that messed up)

>
> Also, layers is not the only collection worth checking. I would also
> check document.images, document.links, etc., for each of the nested
> documents, in order to better simulate document.getElementById.
>
> Well, to be honest, I'd prefer to just drop support for Netscape 4.


Right

Thanks,

Aaron


 
Reply With Quote
 
Aaron Gray
Guest
Posts: n/a
 
      07-11-2008
"Bjoern Hoehrmann" <> wrote in message
news: n.hoehrmann.de...
>* Aaron Gray wrote in comp.lang.javascript:
>>Is anyone in a position to be able to test this code ?

>
> There's http://browsers.evolt.org and there are a number of free virtual
> machine http://en.wikipedia.org/wiki/Categor...ation_software
> products that you can use to set up old operating systems or just iso-
> lated enviroments to run them.


I may well try this if no one comes forward to do tests for me.

Thanks,

Aaron


 
Reply With Quote
 
Aaron Gray
Guest
Posts: n/a
 
      07-11-2008
"Aaron Gray" <> wrote in message
news:...
> Hi,
>
> I know the 'document.getElementById()' issue is really over since every
> browser since 1998 supports the W3C DOM standard, but I could not resist
> this offering :-
>
> if (!document.getElementById)
> document.getElementById = function(id) { return document.all[id]; }
>
> This should then provide a getElementById function if one does not already
> exist.
>
> Is anyone in a position to be able to test this code ?
>


There's a test for document.getElementById() emulation here :-

http://www.aarongray.org/Test/JavaSc...ById-test.html

Thanks,

Aaron


 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      07-11-2008
In comp.lang.javascript message <>,
Fri, 11 Jul 2008 00:21:35, Aaron Gray <> posted:
>
>I know the 'document.getElementById()' issue is really over since every
>browser since 1998 supports the W3C DOM standard, but I could not resist
>this offering :-
>
> if (!document.getElementById)
> document.getElementById = function(id) { return document.all[id]; }
>
>This should then provide a getElementById function if one does not already
>exist.
>
>Is anyone in a position to be able to test this code ?


A version tested in MS IE 4 is at <URL:http://www.merlyn.demon.co.uk/js-
versn.htm#SSF>; I cannot repeat the test.

I don't recall anyone complaining that it did not work in the
circumstances in which I used it. But it does not reproduce all
features.

To get it rested in Netscape 4, I suggest that you ask the custodian of
the Davar site, who posts advertisements here from time to time.
Evidently he is keen to support those hoping to upgrade to Netscape 4.8.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
SAM
Guest
Posts: n/a
 
      07-11-2008
Aaron Gray a écrit :
>
> There's a test for document.getElementById() emulation here :-
>
> http://www.aarongray.org/Test/JavaSc...ById-test.html


a pure soup of tags ... !

--
sm
 
Reply With Quote
 
dhtml
Guest
Posts: n/a
 
      07-11-2008
On Jul 11, 8:20*am, Lasse Reichstein Nielsen <l...@hotpop.com> wrote:
> Svend Tofte <sto...@gmail.com> writes:
> > On Jul 11, 1:21*am, "Aaron Gray" <ang.use...@gmail.com> wrote:

>
> >> document.getElementById = function(id) { return document.layers[id];}

>
> > NS4 Layers are more tricky then that. Layers that are nested will not
> > be exposed through the top level layers array. Example

>
> > document.layers['outerLayer'].document.layers['innerLayer'] (yes, it's
> > that messed up)

>


For that, you'd need either DFS or BFS. DFS is probably going to be
more efficient in JS. Just keep growing the array.

> Also, layers is not the only collection worth checking. I would also
> check document.images, document.links, etc., for each of the nested
> documents, in order to better simulate document.getElementById.
>
> Well, to be honest, I'd prefer to just drop support for Netscape 4.
>


And even with an traversal that accounted for all of that, the result
would still be slow and would miss elements in NS4 (document.body, for
example).

It seems like a lot of bloat just for NS4 support.

The MSIE id/name bug seems to be a bigger concern:
http://www.gtalbot.org/BrowserBugsSe...IE8Bugs/#bug11

> /L

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee Perl Misc 21 03-21-2006 07:02 AM
Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee Python 23 03-21-2006 07:02 AM
Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee Java 22 03-21-2006 07:02 AM
a final fix for those old solution placed here with attachment things nota chance Computer Support 0 08-08-2004 02:41 AM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments