∟DOM Level Test - document.implementation.hasFeature
This section provides a tutorial example of using the document.implementation.hasFeature() method to test DOM levels supported in a particular Web browser.
In DOM Level 1, 2, and 3 specifications, there is one method that will level you to test
what levels of DOM specifications are supported in a specific Web browser:
document.implementation.hasFeature(feature, level). It returns
true, if the specified feature and level is supported by the Web browser.
Note that the level must be specified in the dot format like 1.0, 2.0, or 3.0.
I used this method in the tutorial example to test what levels of DOM are supported
by Web browsers on my machine.
When I use this script to test Internet Explorer 6.0, the result shows that
DOM Core Level 1 is not supported. But DOM HTML Level 1 is supported, very strange.
DOM Level 0 Test:
document.bgColor = #ffffff
DOM Level 1.0 Test:
Core 1.0 = false
HTML 1.0 = true
DOM Level 2.0 Test:
Core 2.0 = false
HTML 2.0 = false
DOM Level 3.0 Test:
Core 3.0 = false
HTML 3.0 = false
When I use this script to test Mozilla FireFox 2.0, the result shows that
DOM Core Level 1 and 2, and DOM HTML Level 2 are supported. But DOM HTML Level 1 is not supported.
DOM Level 0 Test:
document.bgColor = #ffffff
DOM Level 1.0 Test:
Core 1.0 = false
HTML 1.0 = true
DOM Level 2.0 Test:
Core 2.0 = true
HTML 2.0 = true
DOM Level 3.0 Test:
Core 3.0 = false
HTML 3.0 = false