Detecta cambios en la orientación del dispositivo.
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
if (screen.orientation.type != "undefined") {
if (screen.orientation.type.indexOf("portrait") >= 0) {
alert("portrait");
} else if(screen.orientation.type.indexOf("landscape") >= 0) {
alert("landscape");
}
}
}, false);