开发者

Stop bubbling events seems not work on internet explorer in google pages

I am working in a browser extension. I am putting some icons next to links in google search pages. These icons trigger some actions and I need stop bubble events after user clicks on it. In resume, parent div tags must not know about clicks on these icons.

Next code allow stop bubbling events in all browsers:

if (event.cancelBubble) {
        event.cancelBubble = true;
}
if (event.returnValue) {
        event.returnValue = false;
}
if (event.stopPropagation) {
        event.stopPropagation();
}
if (event.preventDefault) {
        event.preventDefault();
}

In Firefox works well but in this context not works in IE (versi开发者_如何转开发on 8 at least). Any idea about it?


if (event.cancelBubble) {
        event.cancelBubble = true;
}

This doesn't make sense. It only sets it to true if it already evaluates to true (in a boolean context). Get rid of the if clause (i.e. always set it unconditionally); setting a non-existant value usally doesn't do any harm (unless you are setting it on a host object which has an ugly implementation)


or try setting it to false, if u use true, the event will fire the code that comes after the event has been fired, when an event has a boolean, it could sometimes mean that u have the freedom to control that event, if u say true, the event may execute other function(s). when saying false the event will not execute other functions, but that only depends on how that function.

coder made his function/code.

but in simple words "To handle or to raise the bubbled event, a control must override the OnBubbleEvent method.", and thats where u do the opposite dont override if u did.

if u havent read this yet http://msdn.microsoft.com/en-us/library/aa719644(v=vs.71).aspx and like i said do the opposite.

; )

Hope this helps u out a bit

Laterss!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜