js自动识别移动客户端,并适配
作者:小鱼的互联网观察 发布时间:May 12, 2017 分类:互联网观察
自动识别移动客户端,并适配
<script>
var inw = window.innerWidth;
var inh = window.innerHeight;
var o = window.orientation;
var w = window.screen.width;
if((navigator.userAgent.indexOf("iPad") != -1 && o != '0') || (navigator.userAgent.indexOf("iPad") != -1 && inw>inh)){
document.write('<meta content="width=device-width, initial-scale=0.8, maximum-scale=1.0, user-scalable=0" name="viewport">');
}else{
document.write('<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">');
}
</script>