开发者

JQuery $(document).onClick doesn't work when clicking an <embed> flash on IE (but it does in FF)

开发者 https://www.devze.com 2023-01-06 13:22 出处:网络
This is the scenario: I\'m developing a dropdown widget in Jquery. I have to say it was simple. The main problem was to catch when the user clicks outside my widget to make it hide its list. I foun

This is the scenario:

I'm developing a dropdown widget in Jquery. I have to say it was simple.

The main problem was to catch when the user clicks outside my widget to make it hide its list. I found this code here:

onClickOutside : function(event, e){
  var thisObject = this;
  var clickedOutside = true; 
  // check if the object itself or its parents are seoDropDown ones.
  $(e).parents().andSelf().each(function () {
    if (this == thisObject) {
      click开发者_Go百科edOutside = false; 
      return false; 
    }
  });
  if (clickedOutside) {
    //hide my widget
  }
},

and it works fine; I bind this to my object like

myWidget.bind("onClickOutside", myWidget.onClickOutside);

and then trigger it using

$(document).click(function (e) {
  $(myWidget).trigger('onClickOutside', [e.target]);
});

Everything works fine EXCEPT if I click an swf movie inside an embed tag in IE.

I'm pretty sure swf's in IE can send some message to javascript, because YUI menu is capable of hiding perfectly even if the outside click was done over a swf object so...... does anybody knows how YUI menu widget is capable of "listening" clicks inside swfs in IE?

Thanks!


Prior art: use onmousedown / onmouseup.

0

精彩评论

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