标签:
最近测试发现,html5游戏在三星note手机上初次加载都会模糊,刷新之后就不模糊了,不知道是什么原因,本人对底层的东西也不熟,后来问了个同事,找到个解决方案,现记录一下。<meta name="viewport" content="width=device-width,target-densitydpi=device-dpi,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> <script type="text/javascript"> var phoneWidth = parseInt(window.screen.width); var phoneScale = phoneWidth / 640; var ua = navigator.userAgent; if (/Android (\d+\.\d+)/.test(ua)) { var version = parseFloat(RegExp.$1); if (version > 2.3) { document.write(‘<meta name="viewport" content="width=640, minimum-scale = ‘ + phoneScale + ‘, maximum-scale = ‘ + phoneScale + ‘, target-densitydpi=device-dpi">‘); } else { document.write(‘<meta name="viewport" content="width=640, target-densitydpi=device-dpi">‘); } } else { document.write(‘<meta name="viewport" content="width=640, target-densitydpi=device-dpi">‘); } </script>添加以上代码到头部就行了。
标签:
原文地址:http://my.oschina.net/lonewolf/blog/364862