/    Sign up×
Community /Pin to ProfileBookmark

document.implementation.hasfeature on IE and FF

Hi forum,

I call this function

[CODE] function showForm() {
if (!document.implementation.hasFeature(“Core”, “3.0”)) {
alert(“1”);//
}
if (!document.implementation.hasFeature(“XML”, “3.0”)) {
alert(“2”);//
}
if (!document.implementation.hasFeature(“HTML”, “2.0”)) {
alert(“3”);
}
if (!document.implementation.hasFeature(“Views”, “2.0”)) {
alert(“4”);
}
if (!document.implementation.hasFeature(“StyleSheets”, “2.0”)) {
alert(“5”);
}
if (!document.implementation.hasFeature(“CSS”, “2.0”)) {
alert(“6”);
}
if (!document.implementation.hasFeature(“CSS2”, “2.0”)) {
alert(“7”);
}
if (!document.implementation.hasFeature(“Events”, “2.0”)) {
alert(“8”);
}
if (!document.implementation.hasFeature(“UIEvents”, “2.0”)) {
alert(“9”);
}
if (!document.implementation.hasFeature(“MouseEvents”, “2.0”)) {
alert(“10”);
}
if (!document.implementation.hasFeature(“MutationEvents”, “2.0”)) {
alert(“11”);//
}
if (!document.implementation.hasFeature(“HTMLEvents”, “2.0”)) {
alert(“12”);
}
if (!document.implementation.hasFeature(“Range”, “2.0”)) {
alert(“13”);
}
if (!document.implementation.hasFeature(“Traversal”, “2.0”)) {
alert(“14”);//
}
if (!document.implementation.hasFeature(“LS”, “3.0”)) {
alert(“15”);//
}
if (!document.implementation.hasFeature(“LS-Async”, “3.0”)) {
alert(“16”);//
}
if (!document.implementation.hasFeature(“Validation”, “3.0”)) {
alert(“17”);//
}
}[/CODE]

on FireFox 3 and only the alert marked with // go off. In IE 8 on the other hand all of them go off. These are features described in JavaScript for WebDevelopers 2nd edition. This cannot possibly mean that IE 8 is missing all these features…what is qrong then?!?!

to post a comment
JavaScript

16 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 25.2010 — [I]hasFeature[/I] is referenced differently IE: http://msdn.microsoft.com/en-us/library/ms761344%28VS.85%29.aspx

The version support varies between browsers: http://www.w3.org/2003/02/06-dom-support.html

This method of feature support is not very useful; an object support is a better approach.

QuirksMode has a full compatibility listing: http://www.quirksmode.org/compatibility.html
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — JScript Syntax

Copy

boolVal = objXMLDOMImplementation.hasFeature(feature, version);

Parameters

feature

A string that specifies the feature to test. In Level 1, valid feature values are "XML", "DOM", and "MS-DOM" (case-insensitive).

version

A string that specifies the version number to test, or if Null, tests for implementation of the feature in any version. In Level 1, "1.0" is the valid version value.

Return Value

Boolean. Returns True if the specified feature is implemented; otherwise False.
[/QUOTE]


how is that hasfeature is referenced differently in IE...explain
Copy linkTweet thisAlerts:
@FangJul 25.2010 — Did you not read the example given in the MS link?
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — Cmon man dont patronize me...can you explain or not?!?!
Copy linkTweet thisAlerts:
@FangJul 25.2010 — Cmon man dont patronize me...can you explain or not?!?![/QUOTE]Can't you be bothered to read the MS documentation????
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var bool = xmlDoc.implementation.hasFeature("DOM", "1.0");
WScript.Echo(bool);
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — Wow incredibly helpful....not!!!! This code is listed under J# example
Copy linkTweet thisAlerts:
@FangJul 25.2010 — function showForm() {
var d = ((window.ActiveXObject))? new ActiveXObject("Msxml2.DOMDocument.3.0") : document;
if (!d.implementation.hasFeature("Core", "3.0")) {
alert("1");//
}
if (!d.implementation.hasFeature("XML", "3.0")) {
alert("2");//
}
if (!d.implementation.hasFeature("HTML", "2.0")) {
alert("3");
}
if (!d.implementation.hasFeature("Views", "2.0")) {
alert("4");
}
if (!d.implementation.hasFeature("StyleSheets", "2.0")) {
alert("5");
}
if (!d.implementation.hasFeature("CSS", "2.0")) {
alert("6");
}
if (!d.implementation.hasFeature("CSS2", "2.0")) {
alert("7");
}
if (!d.implementation.hasFeature("Events", "2.0")) {
alert("8");
}
if (!d.implementation.hasFeature("UIEvents", "2.0")) {
alert("9");
}
if (!d.implementation.hasFeature("MouseEvents", "2.0")) {
alert("10");
}
if (!d.implementation.hasFeature("MutationEvents", "2.0")) {
alert("11");//
}
if (!d.implementation.hasFeature("HTMLEvents", "2.0")) {
alert("12");
}
if (!d.implementation.hasFeature("Range", "2.0")) {
alert("13");
}
if (!d.implementation.hasFeature("Traversal", "2.0")) {
alert("14");//
}
if (!d.implementation.hasFeature("LS", "3.0")) {
alert("15");//
}
if (!d.implementation.hasFeature("LS-Async", "3.0")) {
alert("16");//
}
if (!d.implementation.hasFeature("Validation", "3.0")) {
alert("17");//
}
}
showForm() <br/>
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — did you even test this before posting it...?!?!? It behave exactly as my code did!!!

I am pretty sure your code does the same thing as mine...maybe its some configuration on my IE or machine
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — var x = document.documentMode;

x becomes = 5, which according to JavaScript for WebDevelopers 2nd edition means that my IE 8 runs renders pages in quirks mode (IE 5). This might have something to do with the above...The thing is now...why the hell is IE running in quirks mode?!?!?!
Copy linkTweet thisAlerts:
@FangJul 25.2010 — Are you using a DTD? http://en.wikipedia.org/wiki/Quirks_mode#Triggering_different_rendering_modes

[I]documentMode[/I] is 5 when the DTD is missing or invalid. The script returns the same values irrespective of [I]documentMode [/I]
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — I had omitted

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

from my HTML for experimenting reasons?

Now its equal to 8. The script concerning the hasFeature function still doesnt work!!! Your version of works properly on your PC? Which alerts go off??
Copy linkTweet thisAlerts:
@FangJul 25.2010 — All in IE8
Copy linkTweet thisAlerts:
@msenauthorJul 25.2010 — Ummmm....I dont undertant!!!! My code had the same output. Does this mean that all these features are not implemented in IE 8?!?!?
Copy linkTweet thisAlerts:
@FangJul 25.2010 — No, it means hasFeature is unreliable and of little use in determining module support.

Even if a particular module is supported, it does not mean that all features of the module are supported.

Use object detection.
Copy linkTweet thisAlerts:
@rnd_meJul 25.2010 — i 2nd fang; don't rely on browser-reported features. Just because IE and opera both claim CSS capability doesn't mean the treat CSS the same. Object detection can get you into the same trouble to a lessor extent; i think some degree of old-fashioned browser sniffing is still required to get perfect results from scripts and css.
Copy linkTweet thisAlerts:
@KorJul 26.2010 — I don't see the reason for someone would use the [B]hasFeature[/B] method. It is a well known thing that there is no browser which has implemented all the standard modules of a feature or another. Worst than that, some browsers have wrong implementations, other non-standard implementations or even bugs.
×

Success!

Help @msen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...