473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi,

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

if (!document.getE lementById)
document.getEle mentById = 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.getE lementById)
if (document.all)
document.getEle mentById = function(id) { return
document.all[id]; }
else
document.getEle mentById = function(id) { return
document.layers[id]; }

Reference :-

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

Thanks,

Aaron
Jul 10 '08 #1
6 1834
* Aaron Gray wrote in comp.lang.javas cript:
>I know the 'document.getEl ementById()' issue is really over since every
browser since 1998 supports the W3C DOM standard, but I could not resist
this offering :-

if (!document.getE lementById)
document.getEle mentById = 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 · mailto:bj****@h oehrmann.de · 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/
Jul 11 '08 #2
On Jul 11, 1:21*am, "Aaron Gray" <ang.use...@gma il.comwrote:
document.getEle mentById = 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.layer s['innerLayer'] (yes, it's
that messed up)

Regards,
Svend
Jul 11 '08 #3
"Bjoern Hoehrmann" <bj****@hoehrma nn.dewrote in message
news:1u******** *************** *********@hive. bjoern.hoehrman n.de...
>* Aaron Gray wrote in comp.lang.javas cript:
>>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
Jul 11 '08 #4
"Aaron Gray" <an********@gma il.comwrote in message
news:6d******** ****@mid.indivi dual.net...
Hi,

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

if (!document.getE lementById)
document.getEle mentById = 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.getEle mentById() emulation here :-

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

Thanks,

Aaron
Jul 11 '08 #5
In comp.lang.javas cript message <6d************ @mid.individual .net>,
Fri, 11 Jul 2008 00:21:35, Aaron Gray <an********@gma il.composted:
>
I know the 'document.getEl ementById()' issue is really over since every
browser since 1998 supports the W3C DOM standard, but I could not resist
this offering :-

if (!document.getE lementById)
document.getEle mentById = 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.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 11 '08 #6
SAM
Aaron Gray a écrit :
>
There's a test for document.getEle mentById() emulation here :-

http://www.aarongray.org/Test/JavaSc...ById-test.html
a pure soup of tags ... !

--
sm
Jul 11 '08 #7

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

Similar topics

6
6846
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 anything that explains why my problems occur. Could anyone here see through the included example...
12
10176
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical scrollbar, you get the height of the entire document, screwing up any chance of centering a window in the browser using these values. Is there a way to get the height of the actual browser window and not the entire page height? Thanks.
13
9651
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
15
3327
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange) { var range = document.selection.createRange(); if (range.parentElement() == element) range.text = '<' + tag + '>' + range.text + '<\/' + tag + '>'; }
3
2448
by: InvisibleMan | last post by:
Thanks in Advance for any help on this - its truely sending my head in loops... so I appreciate your efforts! okay, I have a javascript listed below that drops down submenus contained within: <div class="small" style="display: none" id="menu1_menu"> when the heading is clicked: <a href=.. onClick="expandDiv('menu1')">
136
9457
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
7
2408
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one of the questions, that form is hidden and the next is displayed. Also, as the user answers each question a "count" variable is updated based on their response. I would like the question to show up on the left side and the answer to show up in the...
19
4358
by: vunet.us | last post by:
Hello, My AJAX application paints data into about 500 cells with unique ID every 10 seconds. I am using document.getElementById() to find the right cell. However, I have noticed that document.getElementById() in IE is freezing the browser for about 1 second unlike Firefox. Can anyone suggest any speed improvements for painting data into a large number of cells to speed up the process?
0
7520
acoder
by: acoder | last post by:
Problem document.getElementById() selects an element by its name. Browser Internet Explorer Example Relevant HTML code: <input name="test" type="text" value="test"> The Javascript code:
0
9645
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10329
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
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
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
6740
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
5381
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
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 we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.