4

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

yoozer8
  • 7,361
  • 7
  • 58
  • 93
Danny Fox
  • 38,659
  • 28
  • 68
  • 94

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
  • 224,678
  • 48
  • 389
  • 349
Rob W
  • 341,306
  • 83
  • 791
  • 678
  • 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