我試圖檢查Android版本是否小於4與phonegap。檢查android版本是否小於4與phonegap?
我正在使用這個版本。
var deviceOS = device.platform; //fetch the device operating system
var deviceOSVersion = device.version; //fetch the device OS version
alert("Device OS: " + deviceOS);
alert("Device OS Version: " + deviceOSVersion);
並試圖檢查版本是否小於4,但它不工作?
if (deviceOSVersion < 4) {
alert("android less than 4");
}
我測試了一些東西,但沒有運氣。
任何輸入讚賞謝謝。
更新: 我試圖設置最後一個代碼「useAnimations:animationen」爲假如果它是和Android小於4,如果它是iPhone的「animationen」應該是true。 但在iPhone上,它是錯誤的下面的代碼?
var int = 0;
var animationen='';
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady()
{
getDeviceProperty();
}
function getDeviceProperty(){
var deviceOS = device.platform; //fetch the device operating system
var deviceOSVersion = device.version; //fetch the device OS version
alert("Device OS: " + deviceOS);
alert("Device OS Version: " + deviceOSVersion);
if (deviceOS.indexOf('Android') >= 0) {
alert("its an android");
int = parseInt(deviceOSVersion);
if(int<4){
alert("animation false");
animationen=false;
}
alert("apptype = android");
}
else
{
alert("apptype = iphone");
animationen=true;
}
}
var jQT = new $.jQTouch({
useAnimations: animationen
});
它有助於感謝;) – numediaweb
其實你可以簡單地做一個字符串比較:'deviceOSVersion <「4」' – user276648