//使用em单位
var scaleObj = {
documentEle : document.documentElement,
deviceWidth : document.documentElement.clientWidth,
scale : 0,
resetPage : function(){
this.scale = this.deviceWidth/6.4;
this.documentEle.style.fontSize = this.scale + 'px';
},
init :function(falseCode){
this.ChangeDevW();
this.deviceWidth < 640 ? this.resetPage() : falseCode;
},
ChangeDevW : function(){
this.deviceWidth = this.documentEle.clientWidth;
}
};
window.onload = function(){
scaleObj.init(false);
}
window.onresize = function(){
scaleObj.init(scaleObj.documentEle.style.fontSize = 625 + '%');
}; //使用px单位
var vieWport = {
phoneWidth : parseInt(window.screen.width),
phoneScale : this.phoneWidth / 640,
ua : navigator.userAgent,
init : function(){
if (/Android (\d+\.\d+)/.test(this.ua)) {
var version = parseFloat(RegExp.$1);
if (version > 2.3) {
document.write('<meta name="viewport" content="width=640, initial-scale= ' + this.phoneScale + ' ,minimum-scale = ' + this.phoneScale + ', maximum-scale = ' + this.phoneScale + ', target-densitydpi=device-dpi">')
} else {
document.write('<meta name="viewport" content="width=640, initial-scale= ' + this.phoneScale + ' , target-densitydpi=device-dpi">')
}
} else {
document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">')
}
}
} vieWport.init();

  

如果js设置移动端有两种方式 大家可以参考的更多相关文章

  1. 原生js更改css样式的两种方式

    下面我给大家介绍的是原生js更改CSS样式的两种方式: 1通过在javascript代码中的node.style.cssText="css表达式1:css表达式2:css表达式3  &quo ...

  2. 【javascript】原生js更改css样式的两种方式

    下面我给大家介绍的是原生js更改CSS样式的两种方式: 1通过在javascript代码中的node.style.cssText="css表达式1:css表达式2:css表达式3  &quo ...

  3. egg.js 通过 form 和 ajax 两种方式上传文件并自定义目录和文件名

    egg.js 通过 form 和 ajax 两种方式上传文件并自定义目录和文件名 评论:10 · 阅读:8437· 喜欢:0 一.需求 二.CSRF 校验 三.通过 form 表单上传文件 四.通过 ...

  4. HTML中设置背景图的两种方式

    HTML中设置背景图的两种方式 1.background    background:url(images/search.png) no-repeat top; 2.background-image ...

  5. 用js实现九九乘法口诀两种方式

    js实现九九乘法口诀两种方式: 第一种是用户输入一个数弹出所对应的乘法口诀: <script type="text/javascript"> function art( ...

  6. JS中访问对象的两种方式区别

    可以使用下面两种方式访问对象的属性和方法 1.对象名.属性名 对象名.方法名() 2.对象名["属性名"] 对象名["方法名"]() var obj = { n ...

  7. linux 设置开机启动项两种方式

    原文链接:http://blog.csdn.net/karchar/article/details/52489572 有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务. 在解问题之前 ...

  8. keras embeding设置初始值的两种方式

    随机初始化Embedding from keras.models import Sequential from keras.layers import Embedding import numpy a ...

  9. VS中设置#define _CRT_SECURE_NO_WARNINGS的两种方式

    1.我们在编译老的用C语言的开源项目如lua源包的时候,可能因为一些老的.c文件使用了strcpy,scanf等不安全的函数,而报警告和错误,而导致无法编译通过. 2.此时我们有两种解决方案: a.在 ...

随机推荐

  1. Error:Execution failed for task ':xutils:mergeDebugAndroidTestResources'. > No slave process to proc

    Error:Execution failed for task ':xutils:mergeDebugAndroidTestResources'. > No slave process to p ...

  2. centos自带python2.6升级到python2.7。并解决yum pip easy_install pip等模块兼容性问题

    参考原文:  https://www.cnblogs.com/kimyeee/p/7250560.html   https://www.cnblogs.com/galaxy-gao/p/5796488 ...

  3. Object.defineProperty使用技巧

    Object.definedProperty 该方法允许精确添加或修改对象的属性.通过赋值操作添加的普通属性是可枚举的,能够在属性枚举期间呈现出来(for...in 或 Object.keys 方法) ...

  4. JS之原型式的继承

    创建一个Person的构造器 function Person(first, last, age, gender, interests) { this.name = { first, last }; t ...

  5. 接口调用 读取图片报错 Access to the path '' is denied.解决方案

    调用接口 读取服务器上 图片 报错: Server was unable to process request. ---> Access to the path '图片路径' is denied ...

  6. Found 1 slaves: Use of uninitialized value in printf at /usr/local/percona-toolkit/bin/pt-online-schema-change line 8489

    1. problem description: as the title show, i miss the first problem using pt-online-schema-change to ...

  7. Thrift-RPC client in Flume

    Get RpcClient from RpcClientFactory with Reflection programming Message or Event definition in Flum ...

  8. Http重要知识点

  9. Tomcat下JDBC连接样例

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  10. less @import and extend及mixin详解

    在less中,通过 @import (keyword) "filename"的方式引入其他的文件,这个keyword可以是以下6种: referrence referrence这个 ...