If you wish to write a script that can flexibly use W3C DOM or IE 4 DOM depending on its availability, then you can use a functional testing method that first checks Is there a method or property to determine if the browser has the functionality you want.
Here is the code snippet that displays the same -
if (document.getElementById) { // If the W3C method exists, use it } else if (document.all) { // If the all[] array exists, use it } else { // Otherwise use the legacy DOM }
The above is the detailed content of How can I write a script that uses the W3C DOM or IE 4 DOM depending on its availability?. For more information, please follow other related articles on the PHP Chinese website!