Javascript iOS iPad和iPhone用户代理在Phonegap应用程序中不工作
我试图检测设备是iPad还是iPhone,但它不能与模拟器一起工作。如果我在iPad上的safari浏览器中测试它,它就会工作。有区别吗? 对于iphone,它总是使用“else” 这是我的代码:Javascript iOS iPad和iPhone用户代理在Phonegap应用程序中不工作,javascript,ios,cordova,Javascript,Ios,Cordova,我试图检测设备是iPad还是iPhone,但它不能与模拟器一起工作。如果我在iPad上的safari浏览器中测试它,它就会工作。有区别吗? 对于iphone,它总是使用“else” 这是我的代码: var isiPad = navigator.userAgent.match(/iPad/i) != null; $(document).ready(function(){ if(isiPad) { window.location.replace("tab/indexTabStart.html");
var isiPad = navigator.userAgent.match(/iPad/i) != null;
$(document).ready(function(){
if(isiPad)
{
window.location.replace("tab/indexTabStart.html");
}
else {
window.location.replace("smart/indexSmartStart.html");
}
});
请帮帮我,谢谢 您可以尝试phonegap提供的api。 尝试使用
设备。型号
device.model-获取设备的型号名称。
例如:
var string=device.model代码>
描述
device.model返回设备型号或产品的名称。该值由设备制造商设置,同一产品的不同版本可能会有所不同。
有关完整文档,请参见: