Posts Categorized ‘web design’
October 17, 2009 at 11:56 am
No Proprietary CSS Code
One of the biggest issues in older scripts (and in this example) is reliance on proprietary vendor techniques such as document.all, which has limited browser support beyond Internet Explorer. Web standards support open, nonproprietary technologies that work across browsers, and there are certainly alternatives defined by the W3C in its Document Object Model. Two of these alternatives are
document.getElementById(id) Returns an element when passed an id that is the ID attribute of the element;
the ID needs to be unique in the document.
element.getElementsByTagName(tag) Returns a nodeList (JavaScript array) of the matching elements by tag.
There are several examples above where document.all can be seamlessly swapped out with document.getElementById. Replace the following:
var x = document.all(“myDHTML”)
with this:
var x = document.getElementById(“myDHTML”)
And replace this:
var x = document.all.tags(“p”)
with this:
var x = document.getElementsByTagName(“p”)
These two methods are key to W3C-based DOM scripting.
Comments Off