ok, I’m confused about the whole cross-browser stuff. Before I thought that there was just a lot of complicated code i would take a long time ever to understand required to make it work in both browsers. However, having learned more, it seems that both browsers are trying to conform to these w3c standards, meaning that only one type of code is required (i.e. instead of document.all or document.layers use document.getElementById(id) ).
So can you tell me exactly how it works? Here’s my up-to -the-minute understanding of it (i’m sure it’s all very wrong:
You have document.all for IEx.x. However IE5 and above supports document.getElementById(). document.getElementById() is the w3c standard and is supported by Netscape 6 and above. Any netscape below used document.layers
according to w3schools.com, ie4 accounts for 0.3% of users, so to be honest, I’m not worried about catering for it. Netscape<5 account for 3.1% (a lot of which is probably web designers just using it to check their pages work?). 4.6% use Netscape5 or greater. However, i would assume that most users of Netscape for surfing would upgrade their software when it became an upgrade, so i assume that most of this 4.6% will be using Netscape 7, which is compatible with w3c standards, and hence compatible with document.getElementById().
Finally, 83.8% of users use IE>5, and hence are also compatible with document.getElementById().
So surely you’re excluding very few users (a number ever decreasing) by using document.getElementById()?
And to use document.getElementById(), I need to give an id to all the elements of the page (eg a table or a cell or a div). These elements are assigned a class also, which links to styles of a CSS. So to make an element of id ‘m1’ hidden, I need to put in my javascript:
document.getElementById(m1).style.visibility=’hidden’;
And this code will work for just about everyone.
Ok – so that’s it as I understand it. So if anyone has the time, i’d appreciate it if they’d go through what I’ve written and explain where I’m right and where I’ve gone wrong and why.