J'adapte un petit magazine web HTML/CSS/Javascript comme un iApp pour l'iPad avec le grand framework mobile PhoneGap. Tout fonctionne bien, sauf le changement d'orientation du mode portrait au mode paysage.Javascript Orientation Le changement ne fonctionne pas avec PhoneGap sur iPad
J'utilise le code Javascript suivant dans l'en-tête du index.html (portrait):
var isiPad = navigator.userAgent.match(/iPad/i) != null;
var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
function updateOrientation() {
if (isiPad || isiPhone) {
switch (window.orientation) {
case 90:
window.location = "index_landscape.html";
break;
case -90:
window.location = "index_landscape.html";
break;
}
}
}
avec la balise body suivant:
<body onorientationchange="updateOrientation();">
Si je tourne l'iPad en mode paysage , il ne change pas à index-landscape.html.
Est-ce que quelqu'un sait où est le problème? N'est-il pas possible de changer le fichier HTML, en changeant d'orientation dans le framework PhoneGap? En d'autres termes, puis-je utiliser uniquement un fichier HTML (index.html) avec PhoneGap et utiliser CSS pour modifier l'orientation?
Si je consulte l'application en tant que site Web avec le navigateur iPad Safari, le changement d'orientation fonctionne correctement.
Merci pour toute aide!
Trouvé que window.orientation travaillé pour moi sur Android 2.2 avec Droid X en utilisant PhoneGap. –