我正在尝试使用 phonegap 检查 android 版本是否小于 4。
我得到了这个版本。
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);
Run Code Online (Sandbox Code Playgroud)
并尝试使用此检查版本是否小于 4,但它不起作用?
if (deviceOSVersion < 4) {
alert("android less than 4");
}
Run Code Online (Sandbox Code Playgroud)
我已经测试了一些东西,但没有运气。
感谢任何输入。
更新:我试图将最后一个代码“useAnimations:animationen”设置为 false,如果它是 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
});
Run Code Online (Sandbox Code Playgroud)
您需要使用 parseInt 接收到的值,
if( parseInt( deviceOSVersion, 10 ) < 4 )
{
// your code
}
Run Code Online (Sandbox Code Playgroud)
希望有帮助
| 归档时间: |
|
| 查看次数: |
6432 次 |
| 最近记录: |