
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How can I write a script to use either W3C DOM or IE 4 DOM depending on their availability?
If you want to write a script with the flexibility to use either W3C DOM or IE 4 DOM depending on their availability, then you can use a capability-testing approach that first checks for the existence of a method or property to determine whether the browser has the capability you desire.
The following is the code snippet showing 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 }
- Related Articles
- How to access document properties using W3C DOM method?
- How to write a script to access document properties using IE4 DOM method?
- How to get the list of document properties which can be accessed using W3C DOM?
- How can I use the HTML5 canvas element in IE?
- What are the methods supported by W3C DOM?
- How can I bind all events on a DOM element using jQuery?
- HTML DOM Script Object
- How can I use a script to create users in MongoDB?
- How to replace a DOM element with the specified HTML or DOM elements using jQuery?
- HTML DOM write() Method
- How can I remove all child elements of a DOM node in JavaScript?
- How to write a regular expression to match either a or b in Python?
- How can I access document properties using Legacy DOM method in JavaScript?
- How can I get the ID of an DOM element using jQuery?
- How to use JavaScript DOM to change the padding of a table?

Advertisements