Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a cursor style is supported

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

like image 610
Danny Fox Avatar asked Dec 28 '22 08:12

Danny Fox


1 Answers

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

like image 168
Rob W Avatar answered Jan 13 '23 12:01

Rob W