标签:console back else ack navig width 其他 agent logs
判断终端并对相应的终端进行不同处理方法(函数)
$("#btn_download").click(function () {
var u = navigator.userAgent;
var isAndroid = u.indexOf(‘Android‘) > -1 || u.indexOf(‘Adr‘) > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
$("#lucencyBg").show();
if (isAndroid) {
//android终端处理函数
alert(‘是否是Android:‘+isAndroid);
}else if(isiOS){
//ios终端处理函数
alert(‘是否是iOS:‘+isiOS);
}else{
alert("其他浏览器");
}
});
附:jQuery处理背景图片不能撑满屏幕:
$("#_main").height(window.innerHeight);
//两种方法可选,可根据需要选择
//window.screen.height
//window.innerHeight
//console.log(window.screen.height);
这样css代码就不用写高度了,但是要加上几句css:
#_main{ width: 100%; background: url("../images/QRBg.png") 0 0 no-repeat; /*需要添加下面的代码*/ background-size: 100% auto; display: flex; justify-content: center; }
jQuery 判断终端是IOS还是Android / jQuery处理背景图片不能撑满屏幕
标签:console back else ack navig width 其他 agent logs
原文地址:http://www.cnblogs.com/tzdy/p/7567558.html