1
window.onresize = function(){ updateOrientation(e); }
function updateOrientation(e) {
alert("hey");
deviceWidth = $('body').width();
if (deviceWidth == 320) {
currentOrientation = "portrait";
}
else if (deviceWidth == 480) {
currentOrientation = "landscape";
}
// fire a function that checks the orientation every x milliseconds
setInterval(checkOrientation, 500);
// check orientation
function checkOrientation() {
deviceWidth = $('body').width();
if (deviceWidth >= '1200') {
newOrientation = "portrait";
}
else if (deviceWidth <= '900') {
newOrientation = "landscape";
}
// if orientation changed since last check, fire either the portrait or landscape function
if (newOrientation != currentOrientation) {
if (newOrientation == "portrait") {
changedToPortrait();
}
else if (newOrientation == "landscape") {
changedToLandscape();
}
currentOrientation = newOrientation;
}
}
// landscape stuff
function changedToLandscape() {
alert('Orientation has changed to Landscape!');
}
// portrait stuff
function changedToPortrait() {
alert('Orientation has changed to Portrait!');
}
}
나는 phonegap을 사용하여 안드로이드 타블렛의 방향 변경을 감지하는데 이것을 사용하고 있습니다. 어떻게 든 코드가 작동하지 않습니다. 어떤 제안? 추측으로 방향 변경 이벤트를 생성 할 수 없습니다.전화 걸기의 방향 변경
는 안드로이드 응용 프로그램을 개발? – Mkpatel