How can I check, with JavaScript, whether cursor:none
is supported?
Asked
Active
Viewed 276 times
4
1 Answers
10
Simply create an element, set the property, and check whether the property is still existent.
function isCursorNoneSupported() {
var a = document.createElement("a");
a.style.cursor = "none";
return a.style.cursor === 'none';
}
if ( isCursorNoneSupported() ) {
alert("cursor:none is supported!");
} else {
alert("cursor:none is not supported :(");
}
To check which browsers support cursor:none
, have a look at: cursor
Browser compatibility
-
2@refhat `===` is an identity operator. In this case, it doesn't matter whether you're using `==` or `===`, because both objects are a string. For more details on `===` vs `==`, see [JavaScript === vs == : Does it matter which “equal” operator I use?](http://stackoverflow.com/questions/359494/javascript-vs-does-it-matter-which-equal-operator-i-use) – Rob W Jan 07 '12 at 20:28