js中怎么覆盖事件

JavaScript09

js中怎么覆盖事件,第1张

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<script>

function myblur () {

alert("1、离开")

}

function bindEvent(func){

myblur = func

}

function myonclick() {

bindEvent(function(){

alert("天啊!myblur方法被覆盖了!")

})

}

</script>

</head>

<body>

<input type="text" onblur="myblur()" value="光标选中然后光标离开会调用myblur()方法"/>

<input type="button" onclick="myonclick()" value="覆盖myblur()" />

注:覆盖myblur()后,再次光标选中输入框然后再离开

</body>

</html>

<body onload="getNewPage()">

函数getNewPage(){

window.location.href = "xxxxx"

}