Codesnipp.it Social Code Sharing

Thomas

checking device orientation

by Thomas on Nov 04, 2011

window.addEventListener('orientationchange', setOrientation, false); function setOrientation() { var orient = Math.abs(window.orientation) === 90 ? 'landscape' : 'portrait'; if (orient == "portrait") { window.alert("This app is only available in landscape mode, please switch back"); $("html").css("display", "none"); } else { $("html").css("display", "block"); } }

Can't see the comments? Please login first :)