一、首先是ios对时间date()的支持不一样:
var date =new Date("2016-05-31 00:00:00");
这种写法在安卓和pc上都不正常的,唯独在ios手机上会显示Nan,查阅一些资料,经过一番调试发现:
ios上只支持:
var date =new Date("2016/05/31");
这种格式,调试发现 2016/05/31 等同 2016-05-31 00:00:00 ,也就是说ios默认就是从0开始计算的,我们不需要设置后面的时分秒为 00:00:00
二、安卓手机端软键盘弹出顶起页面布局:
BODY被顶起的解决办法:
$('body').height($('body')[0].clientHeight);
三、调用系统自带alert的时候会有网址显示:
去掉网址解决办法:
window.alert = function(name){var iframe = document.createElement("IFRAME");iframe.style.display="none";iframe.setAttribute("src",'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);}
四、音乐视频video与audio不能自动播放:
这行代码在pc与安卓手机浏览器上都是正常的,唯独在ios上不能自动播放。
解决方案一:
function autoPlayAudio1() { wx.config({ // 配置信息,即使不正确也能使用 wx.ready debug: false, appId: '', timestamp: 1, nonceStr: '', signature: '', jsApiList: [] }); wx.ready(function() { document.getElementById('audio').play(); }); }
解决方案二:
document.addEventListener('WeixinJSBridgeReady',function() { audio.play(); },false);
}
Safari浏览器自动播放
document.addEventListener('touchstart',function(){ audio.play();},false);