Html5 手机网页中,长按会触发系统事件,请问怎么取消这些事件

html-css06

Html5 手机网页中,长按会触发系统事件,请问怎么取消这些事件,第1张

在页面中样式中加上下面的css代码

*{

-webkit-overflow-scrolling: touch

-webkit-touch-callout:none

-webkit-user-select:none

-khtml-user-select:none

-moz-user-select:none

-ms-user-select:none

user-select:none

}

<td id="mytd"></td>

<script type="text/javascript">

var tddom= document.getElementById('mytd')

var timer = null

tddom.onmousedown = function(){

timer = setTimeout( doStuff, 2000 )//这里设置时间

}

tddom.onmouseup = function(){

clearTimeout( timer )

}

function doStuff() {

alert('hello, you just pressed the td for two seconds.')

}

</script>