移動開發經常使用技術總結!~~

//判斷PC端跟MB端事件javascript

var touchEnd = ('ontouchstart') in window ? 'touchend' : 'mouseup';java

 

//安卓機點擊按鈕出現藍色邊框
-webkit-tap-highlight-color: rgba(255, 0, 0, 0);web


//移動端頭部格式
<head>
<meta charset="UTF-8">
<meta id="viewport" name="viewport" content="width=device-width; initial-scale=1; maximum-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 content="telephone=no, email=no" name="format-detection" />
<meta http-equiv="pragma" content="no-cache" />
<!-- windows phone 點擊無高光 -->
<meta name="msapplication-tap-highlight" content="no">
<!-- 設置瀏覽器緩存 -->
<meta http-equiv="Cache" content="no-cache">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" />
<meta name="csrf-param" content="_csrf">
<meta name="csrf-token" content="d3RGNlZVTWseNwRUZRMCMhMXCX1mOA46ExIqVwJjLAQADhVBDhZ.Rg==">
<title>HIKEE黑金鑽微官網</title>
</head>windows


//Touch事件定義
var hasTouch = 'ontouchstart' in window ? true : false,
touchEnd = hasTouch ? 'touchend' : 'mouseup';瀏覽器


//移動端內容隨着分辨率相對應放大縮小
<script type="text/javascript">
if(/Android (\d+\.\d+)/.test(navigator.userAgent)){
var version = parseFloat(RegExp.$1);
if(version>2.3){
var phoneScale = parseInt(window.screen.width)/640;
document.write('<meta name="viewport" content="width=640, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +', target-densitydpi=device-dpi">');
}else{
document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
}
}else{
document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
}
</script>緩存

相關文章
相關標籤/搜索