4

How can I check, with JavaScript, whether cursor:none is supported?

yoozer8
  • 7,194
  • 6
  • 53
  • 88
Danny Fox
  • 35,333
  • 28
  • 67
  • 92

1 Answers1

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

thirtydot
  • 217,782
  • 47
  • 385
  • 346
Rob W
  • 328,606
  • 78
  • 779
  • 666
  • 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