4

jQuery uses event bubbling, but is there a way to do event capturing ie in the descending order as explained here

The specific case is the following where host A & host B are on the same domain like : www.mydomain.com and xxx.mydomain.com. Of course the Same Origin Policy makes it that it is not possible to trigger on event in the iframe. However I just would like to know if user has clicked on $('#hostA') and pass on the event to the <iframe>.

<div id="hostA"> <iframe id="hostB"> </div>

millebii
  • 1,267
  • 2
  • 17
  • 27
  • You can traverse down yourself; see http://jsfiddle.net/7u87c/72/ **Note:** I didn't write the html/css; it is from [this question](http://stackoverflow.com/a/20415790/578023) – That Realty Programmer Guy Apr 06 '14 at 06:57

1 Answers1

5

No, jQuery does not support this and it never can -- IE has no way to implement a capturing event.

None
  • 1
  • 30
  • 155
  • 213
  • I can do if it only works on FF or Chrome. Would there be a solution in that case. – millebii Jun 15 '11 at 08:11
  • 1
    FYI, this isn't what you asked, but if you run this from both frames, you'll be able to trigger events cross-sub domain: `document.domain = document.domain.replace(/.*?([^\.]+\.[^\.]+)$/, '$1');` – None Jun 15 '11 at 08:15
  • 3
    per the Mozilla docs, addEventListner has a capturing property. You could theoretically modify jQuery's `.bind` to use this if you desire. https://developer.mozilla.org/en/DOM/element.addEventListener – None Jun 15 '11 at 08:17
  • @cwolves IE9 and below doesn't support addEventListener. – John Kurlak May 30 '13 at 20:11
  • 1
    Sorry, need to clarify: below IE9 doesn't support it. IE9 supports it, but only on standards mode. – John Kurlak May 30 '13 at 21:26