错,<input type="button"  value="hello"  onmousedown="alert('22222');"  onclick=alert('33333');>onclick也不响应?

解决方案 »

  1.   

    试过了完全可以。文件贴你<input type="button"  value="hello" onclick=alert('33333');>
    这是整个文件,试试
      

  2.   

    可能是ie本身的问题吧,它把onmousedown和onclick区分不是很明显,onmousedown执行过后,就不会执行onclick了,但是我在firefox中测试是正确的,不过先是执行onclick,再之后是onmousedown
      

  3.   

    正确的啊,只是可能onmousedown事件里本来就已经包含onclick
    如果你这两个事件都用鼠标点击,肯定是执行onmousedown在先,而不会执行onclick
    如果你用键盘测试的话,你就能做出效果了,我想做了之后,能明显找出两者的区别
      

  4.   

    没错,我咱天也是用键盘测发现可以执行onclick,可是用鼠标就只执行onmousedown.
      

  5.   

    还有,为何<input type="button"  value="hello"  onmousedown="var iii='1111';alert('22222');"  onclick=alert(iii);>用键盘触发这个onclick时,提示iii没有定义.
    可是使用<input type="button"  value="hello"  onmousedown=var iii='1111';  onclick=alert(iii);>就能打出iii.
    使用<input type="button"  value="world"  onmousedown=var iii='1111';alert("22222");  onclick=alert(iii);>alert("22222")打不出来.
      

  6.   

    <input type="button"  value="hello"  onmousedown="var iii='1111';alert('22222');"  onclick=alert(iii);>为何不响应呢?------
    一次配对的mousedown和mouseup 都发生在同一个对象上,才叫触发click事件。
    以上的代码,mousedown后,焦点立即跑到alert对话框上去了,跟这个mousedown配对的mouseup不可能还发生在这个button上。所以这个button的click事件无法被触发。
      

  7.   

    看一看html的帮助文件里是怎么说的:onclick被触发的几种:情况
    1.Click the object. 
    2.Invoke the click method. 
    3.Press the ENTER key in a form. 
    4.Press the access key for a control. 
    5.Select an item in a combo box or list box by clicking the left mouse button or by pressing the arrow keys and then pressing the ENTER key. 对于第一种情况,也就是楼主所提到的,作了特别的说明:
    If the user clicks the left mouse button, the onclick event for an object occurs only if the mouse pointer is over the object and an onmousedown and an onmouseup event occur in that order. For example, if the user clicks the mouse on the object but moves the mouse pointer away from the object before releasing, no onclick event occurs.
      

  8.   

    非常感谢JK_10000(JK)
    现在还有一个问题:
    <input type="button"  value="world"  onmousedown="javascript:var iii='1111';"  onclick=alert(iii);>
    问何提示iii未定义,这个郁闷.
      

  9.   

    <input type="button"  value="world"  onmousedown="iii='1111'; "  onclick=alert(iii);>
    <input type="button"  value="world"  onmousedown="window.iii='222'; "  onclick=alert(window.iii);>
    <input type="button"  value="world"  onmousedown="this.iii='333'; "  onclick=alert(this.iii);>