移動端 觸摸事件 ontouchstart、ontouchmove、ontouchend、ontouchcancel

來源:互聯網
上載者:User

標籤:css   遊戲   pad   關係   use   net   detail   htm   手機   

http://www.cnblogs.com/foolisher/p/5412723.html

http://blog.csdn.net/b7995547/article/details/48951761

http://www.cnblogs.com/koukouyifan/p/4066567.html

css device-width如何在js中擷取

 

0,js判斷是手機還是pc:

function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

var flag = IsPC(); //true為PC端,false為手機端

1、Touch事件簡介

pc上的web頁面滑鼠會產生onmousedown、onmouseup、onmouseout、onmouseover、onmousemove的事件,但是在移動終端如iphone、ipod Touch、ipad上的web頁面觸屏時會產生ontouchstart、ontouchmove、ontouchend、ontouchcancel事件,分別對應了觸屏開始、拖拽及完成觸屏事件和取消。當按下手指時,觸發ontouchstart;當移動手指時,觸發ontouchmove;當移走手指時,觸發ontouchend。當一些更進階別的事件發生的時候(如電話接入或者彈出資訊)會取消當前的touch操作,即觸發ontouchcancel。一般會在ontouchcancel時暫停遊戲、存檔等操作。 2、Touch事件與Mouse事件的出發關係

在觸屏操作後,手指提起的一刹那(即發生ontouchend後),系統會判斷接收到事件的element的內容是否被改變,如果內容被改變,接下來的事件都不會觸發,如果沒有改變,會按照mousedown,mouseup,click的順序觸發事件。特別需要提到的是,只有再觸發一個觸屏事件時,才會觸發上一個事件的mouseout事件

移動端 觸摸事件 ontouchstart、ontouchmove、ontouchend、ontouchcancel

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.