一些常用的页面兼容记录

前沿

记录常用的一些兼容性问题

一、meta标签记录
1. 1、name = viewport
  <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0, width=device-width, viewport-fit=cover">
  说明:
     content属性值 :
     width:可视区域的宽度,值可为数字或关键词device-width
     height:同width
     intial-scale:页面首次被显示是可视区域的缩放级别,取值1.0则页面按实际尺寸显示,无任何缩放
     maximum-scale=1.0, minimum-scale=1.0;可视区域的缩放级别,
     maximum-scale用户可将页面放大的程序,1.0将禁止用户放大到实际尺寸之上。
     user-scalable:是否可对页面进行缩放,no 禁止缩放
1. 2、name = format-detection
  <meta name="format-detection" content="telephone=no, email=no,adress=no" />
  说明:
     content属性值 :
     telephone:禁止了把数字转化为拨号链接
     email:禁止作为邮箱地址
     adress:禁止跳转至地图
1.3、 其它浏览器私有meta
  <meta name="screen-orientation" content="portrait">
  <meta name="browsermode" content="application">
  <meta name="wap-font-scale" content="no">
二、meta标签记录
2.1、 IOS10以上不识别放大meta标签,禁止双指缩放、双击缩放
 document.documentElement.addEventListener('touchstart', function (event) {
    if (event.touches.length > 1) {
      event.preventDefault();
    }
  }, false);
  var lastTouchEnd = 0;
  document.documentElement.addEventListener('touchend', function (event) {
    var now = Date.now();
    if (now - lastTouchEnd <= 300) {
      event.preventDefault();
    }
    lastTouchEnd = now;
  }, false);
2.2、 兼容Object.assign拷贝
if (typeof Object.assign != 'function') {
 // Must be writable: true, enumerable: false, configurable: true
  Object.defineProperty(Object, "assign", {
    value: function assign(target, varArgs) { // .length of function is 2
      'use strict';
      if (target == null) { // TypeError if undefined or null
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = Object(target);

      for (var index = 1; index < arguments.length; index++) {
        var nextSource = arguments[index];

        if (nextSource != null) { // Skip over if undefined or null
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    },
    writable: true,
    configurable: true
  });
}
2.3、 兼容Object.keys拷贝
if (!Object.keys) Object.keys = function(o) {
  if (o !== Object(o))
    throw new TypeError('Object.keys called on a non-object');
  var k = [], p;
  for (p in o) if (Object.prototype.hasOwnProperty.call(o, p)) k.push(p);
  return k;
}
结束语

持续记录中,如有错误,欢迎批评指正~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值