Javascript 使用递归更改事件处理程序

Javascript 使用递归更改事件处理程序,javascript,events,dom,Javascript,Events,Dom,我不确定如何做到这一点,并尝试了以下方法,但均无效: someElement.onmouseover=function(event) { if(!event) { e = window.event; } if(event.typeof=="mouseup") { //change what [i]this[/i] returns (this = null doesn't work either) //and how could I find a way to allow this e

我不确定如何做到这一点,并尝试了以下方法,但均无效:

someElement.onmouseover=function(event) {
 if(!event) { e = window.event; }
 if(event.typeof=="mouseup") {
  //change what [i]this[/i] returns (this = null doesn't work either)
  //and how could I find a way to allow this event handler to alter itself under the       
 }
}
任何帮助都将不胜感激

> someElement.onmouseover=function(event)
> {  if(!event) { e = window.event; } 
我想你的意思是:

  event = window.event
  if (event.type == 'mouseup') {
this.onmouseover = someOtherFunction;

我想你的意思是:

  event = window.event
  if (event.type == 'mouseup') {
this.onmouseover = someOtherFunction;

函数的this关键字的值是在实例化期间设置的,您不能更改它

> //and how could I find a way to allow
> this event handler to alter itself
> under the         } }
改变自己?它可以设置不同的侦听器,如果这是您的意思:

  event = window.event
  if (event.type == 'mouseup') {
this.onmouseover = someOtherFunction;
编辑 玩这个:

<script>
  function showType(e) {
    console.log(e.type);
  }
</script>

<input
  onclick="showType(event);"
  onmouseover="showType(event);"
  onmouseout="showType(event);"
  onmousedown="showType(event);"
  onmouseup="showType(event);"
  onkeydown="showType(event);"
  onkeyup="showType(event);"
  onkeypress="showType(event);"
  value="Do stuff in here"
>

功能显示类型(e){
console.log(e.type);
}

你的问题对我来说毫无意义。你能描述一下你想要达到的最终结果吗?对不起。我想让一个事件处理程序通过递归来改变它的工作方式,特别是当一个外部对象发生事件时,它可以触发这种改变(例如,如果aElement.onmouseover发生,并且该事件的处理程序发现bElement.onmouseup正在传输,那么aElement.onmouseover将返回false)。谢谢。如果(event.type==“mouseup”)在鼠标按钮松开时不响应,event.typeof.Help也不响应,请?:(是否有任何错误阻止我获取事件类型?我需要做的是从事件处理程序中获取事件类型,然后检查该事件的源,然后在某些条件下更改当前侦听器。event.type是事件,事件对象的各种属性列在下。