自动在页面插入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); //添加标签
})();
Last modification:March 9, 2024
If you think my article is useful to you, please feel free to appreciate