Opera firing mouse events on disabled input elemen

2019-08-22 03:53发布

I have an image element, following is the html for the button

<input type="image"src="images/undo.png" onmouseover="this.src='images/undo-hover.png'" onmouseout="this.src='images/undo.png'"  id="btn_back" onClick="back();" >

When my application makes this input disabled (attribute disabled="disabled") all browsers stop firing mouse events. So I don't get hover images. But opera still keeps firing these event, and I keep getting the hover images on disabled elements.

3条回答
我想做一个坏孩纸
2楼-- · 2019-08-22 04:33

Can you please try making the INPUT element disabled by default (add disabled="disabled" in the INPUT tag from start). Then see if Opera is still responding to mouse hover. This may not fix the issue right away but will help in figuring out the cause.

Also, another approach could be to call the JS function on mouse event and check if the element is disabled or not. If it is disabled then dont change the src attribute.

HTH,

查看更多
Juvenile、少年°
3楼-- · 2019-08-22 04:33

It seems like an expected behavior in opera, Please see the following link.

http://www.quirksmode.org/dom/events/click.html

It says that "A click event on a disabled form field does not fire events in Firefox and Safari. Opera fires the mousedown and mouseup events, but not the click event. IE fires mousedown and mouseup, but not click, on the form. All these implementations are considered correct."

Thanks, Unnikrishnan B.

查看更多
Melony?
4楼-- · 2019-08-22 04:42

this is a bug in Opera as we're apparently doing something different than other browsers. Please report it on https://bugs.opera.com/wizard/ and give me the bug ID.

That said, I don't think what you are relying on is standardised anywhere, so possibly you should not write code that depends on this somewhat quirky behaviour. The "disabled" attribute merely means that the element will not do its normal action when clicked. I don't really see any reason why setting disabled should prevent firing mouseover/move. It's easy to check from JS if the button is disabled and not swap the image if it is.

查看更多
登录 后发表回答