javascript中的window和document特殊事件
页面离开时的confirm提示
window.onbeforeunload = function() { return ‘你确认要离开吗?‘; };
页面加载完成的事件(在onload之后调用)
document.onreadystatechange = function() { if(document.readyState==‘complete‘) { } }
触摸事件
function load (){ document.addEventListener(‘touchstart‘,touch, false); document.addEventListener(‘touchmove‘,touch, false); document.addEventListener(‘touchend‘,touch, false); function touch (event){ var event = event || window.event; var oInp = document.getElementById("inp"); switch(event.type){ case "touchstart": oInp.innerHTML = "Touch started (" + event.touches[0].clientX + "," + event.touches[0].clientY + ")"; break; case "touchend": oInp.innerHTML = " Touch end (" + event.changedTouches[0].clientX + "," + event.changedTouches[0].clientY + ")"; break; case "touchmove": event.preventDefault(); oInp.innerHTML = " Touch moved (" + event.touches[0].clientX + "," + event.touches[0].clientY + ")"; break; } } } window.addEventListener(‘load‘,load, false);
html5滚轮控件 http://www.17sucai.com/pins/7750.html
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。