Don’t use document.all
11th August 2003
I’ve lost count of the number of Javascript scripts I’ve seen floating around that include the equivalent of the following code snippet:
if (document.all) {
element = document.all[id];
else {
element = document.getElementById(id);
}
document.all
was introduced in Internet Explorer 4, because the W3C DOM hadn’t yet standardised a way of grabbing references to elements using their ID. By the time IE 5 came out, document.getElementById() had been standardised and as a result, IE 5 included support for it.
IE 5 was released in September 1998. A popular browser statistics site (insert usual disclaimer as to the reliability of any stats but your own here) show IE 4’s market share to be in the region of 1%. Even Netscape 4 has more users than that!
Don’t use document.all
. document.getElementById()
is supported by every Javascript supporting browser released since 1998.
More recent articles
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024
- Visualizing local election results with Datasette, Observable and MapLibre GL - 9th November 2024
- Project: VERDAD - tracking misinformation in radio broadcasts using Gemini 1.5 - 7th November 2024