Skip to content Skip to sidebar Skip to footer

How To Check For A Device/browser That Fully Supports The Deviceorientation Event?

I have a HTML5 compass that works quite ok. Now I need a smart way to distinguish between 'pseudo deviceorientation enabled' browsers (as desktop chrome and FF) and real candidates

Solution 1:

it seems to work as is, I was wrong, chrome on mac book is not going into the "real compass" section. should have tested it, maybe.

if (window.DeviceOrientationEvent && 'ontouchstart' in window) {
    // setup real compass thing, with event.alpha
    document.body.innerHTML = "haz!";
} else {
    // setup some mouse following hack
    document.body.innerHTML = "nope";
}

check yourself: http://jsfiddle.net/benzkji/J58ef/

remains what happens if a touch enabled windos laptop with deviceorientation enabled chrome is showing up. probably check the "absolute" property of the deviceorientation event: https://developer.mozilla.org/de/docs/WebAPI/Detecting_device_orientation


Post a Comment for "How To Check For A Device/browser That Fully Supports The Deviceorientation Event?"