常用操作

1.截取当前网页的url

var arr = location.search.substr(1).split('&');
var param_obj = {}; //存储参数的对象
for(var i=0;i<arr.length;i++){
	var str = arr[i];
	if(str == '')break;
	param_obj[str.substr(0,str.indexOf('='))] = str.substr(str.indexOf('=')+1);
}

2.页面跳转

window.location.href='http://www.taobao.com';

3.移动端页面必加

<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />//必备神器

4.移动端兼容

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection"content="telephone=no, email=no" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
<meta name="format-detection" content="telphone=no, email=no" /><!-- 忽略页面中的数字识别为电话,忽略email识别 -->
<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">
<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">
<!-- 适应移动端end -->

5.移动端事件:tap /touch

6.设计图尺寸问题 

设计师在设计移动端UI图时,通常会以iphone5(320*568)或者iphone6(375*627)的分辨率的2倍作为基准设计,比如设计师以iPhone5为基准设计,那么前端开发人员拿到的PSD图尺寸就为640*1136。但web开发人员在实际页面制作过程中,需要将这张2倍图的尺寸相应的缩小一倍换算为最终值。比如在PSD图中标注的间距为40px,则在css中需要缩小为20px。

原文地址:https://www.cnblogs.com/changyuqing/p/5588234.html