阻止彈性滾動
<script>
functionBlockMove(event){
//Tell Safari not to move the window.
event.preventDefault();
}
</script>
<body ontouchmove=”BlockMove(event);”>
…
</body>
檢測螢幕是否旋轉
···//Detect whether device supports orientationchange event, otherwise fall back to
//the resize event.
varsupportsOrientationChange="onorientationchange"inwindow,
orientationEvent=supportsOrientationChange?"orientationchange":"resize";
window.addEventListener(orientationEvent,function(){
alert(`HOLY ROTATING SCREENS BATMAN:`+window.orientation+" "+screen.width);
},false);···
禁止webapp跳轉到safari(for ios)
indow.navigator.standalone){
// If you want to prevent remote links in standalone web apps opening Mobile Safari, change `remotes` to true
varnoddy,
remotes=false;
document.addEventListener(`click`,function(event){
noddy=event.target;
//Bubble up until we hit link or top HTML element. Warning: BODY element is not compulsory so better to stop on HTML
while(noddy.nodeName!=="A"&&noddy.nodeName!=="HTML"){
noddy=noddy.parentNode;
}
if(`href`innoddy&&noddy.href.indexOf(`http`)!==-1&&(noddy.href.indexOf(document.location.host)!==-1||remotes)){
event.preventDefault();
document.location.href=noddy.href;
}
},false);
}
阻止旋轉螢幕時自動調整字型大小
-webkit-text-size-adjust:none;
IOS中禁止使用者選中文字
-webkit-user-select:none;
iOS中如何禁止使用者儲存圖片 複製圖片
-webkit-touch-calloutt:none;
語音輸入
<input type="text"x-webkit-speech />
檔案上傳, 從相機捕獲媒體
<input type="file"accept="image/*; capture=camera" />
<input type="file"accept="video/*; capture=camcorder" />
<input type="file"accept="audio/*; capture=microphone" />
相容安卓微信呼叫攝像頭
<input type="file" name="file" capture="camera">
相容安卓預設選擇sd卡上的相簿圖片
<input type="file" name="file" accept="image/*" >
傳送簡訊給多個人
<a href="sms:18888886666,18888885555"> 傳送簡訊給多個人