让网页视口适应手机端 简单的JS实现
自动在页面插入meta 标签 并设置视口
(function(){
var w = window.screen.width; //屏幕宽度
var targetW = 320;
var scale = w/targetW; //当前尺寸/目标尺寸 缩放比例
var meta = document.createElement("meta");
meta.name = "viewport";
meta.content = "user-scalable=no,initial-scale="+scale+",minimum-scale="+scale+",maximum-scale="+scale+""
document.head.appendChild(meta); //添加标签
})();