5.13

//获取屏幕可视区域的宽高(仿jQuery)
function client(){
if(window.innerHeight !== undefined){
return {
"width": window.innerWidth,
"height": window.innerHeight
}
}else if(document.compatMode === "CSS1Compat"){
return {
"width": document.documentElement.clientWidth,
"height": document.documentElement.clientHeight
}
}else{
return {
"width": document.body.clientWidth,
"height": document.body.clientHeight
}
}
}

//阻止时间冒泡
var box = document.getElementById("box");
box.onmouseover = function (event) {
console.log("鼠标放到了box上");
//阻止冒泡
event = event || window.event;

if(event && event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble = true;
}
}

//捕获时间对象(兼容性写法)
box.onclick=function(event){
event=event=||window.event;
var aaa=event.target?event.target:event.srcElement;
}

猜你喜欢

转载自www.cnblogs.com/vzaiBoke/p/9032144.html