Creating DHTML Applications - (3/8)
Creating DHTML Applications
So, I will start with the 'deepest' level, the 'DOM level,' because that will be the base for the 'PROPERTY level,' which, on itself will be the base for the 'BEHAVIOR level.'
Solving problems on the DOM-level: the mElement() function
The 'mElement()' function is the function that I have created to refer to objects in a document. Let's have a look at an example (opens in new window) that shows the different uses of the mElement function.
Unfortunately this standard has not been implemented in all browsers, therefore the mElement() function deals with 2 exceptions on that standard: old versions of MSIE will use a 'document.all.elementName' syntax, and Netscape a completely different syntax.
Netscape 4.x browsers are implemented as follows:
|mElement syntax||Netscape syntax|
Older MSIE browsers that use the 'document.all' syntax, will only take the first argument of the mElement function into consideration, and will use that argument to create a 'document.all' string, e.g.:
mElement('myImage2','mainLayer','iMageZ') would create:
Finally, all other browsers will use the 'document.getElementById' syntax. For these browsers, mElement is also only taking the first argument of the function, and is constructing a W3C standard string, e.g.:
mElement('myImage2','mainLayer','iMageZ') would be:
So the function builds a string depending on the browser capabilities (not the browser details). Then the function 'evaluates' the string to create and return the required DOM object.
Exceptions are fairly easy to add, which makes this function relatively 'future proof' and easy to maintain.
- Case Study
Created: July 23, 2001
Revised: July 23, 2001