Skip to content

$(domnode) doesn't work for DOM nodes inside IFRAMEs #667

Closed
sciyoshi opened this Issue Dec 21, 2012 · 2 comments

3 participants

@sciyoshi

If you pass a DOM element from an IFRAME to the $() constructor, it fails with an error. This is because the check $.isObject does not pass, since the DOM nodes (iframe.contentDocument.head/body) are actually instances of iframe.contentWindow.Object.

@asual
asual commented Dec 22, 2012

I'm fighting with a very similar issue since yesterday. In my scenario I have an Ajax XML response in the top window that I pass as a reference to dynamically created iframes. When I try to select anything in that XML from inside the iframe I'm getting an error because internally the object detection fails. The reason is that the (XMLElement instanceof Object) check does not return true. It does so in the top window.

I was able to fix the issue by using top.$() instead of $() inside the iframe. Obviously it's not a nice fix. I just tried the same scenario using the latest jQuery and it works fine.

@mislav mislav added a commit that closed this issue Dec 23, 2012
@mislav mislav more robust object type checks, taken from jQuery
This fixes operating on DOM elements within iframe.

Fixes #667

Thanks:
* John Resig
* John-David Dalton
* Rafaël Blais Masson
* Robert Katić
* Ariel Flesler
b451f22
@mislav mislav closed this in b451f22 Dec 23, 2012
@mislav
Collaborator
mislav commented Dec 23, 2012

Fixed! Thanks for the report

@lopper lopper added a commit to buddydvd/zepto that referenced this issue Apr 24, 2013
@mislav mislav more robust object type checks, taken from jQuery
This fixes operating on DOM elements within iframe.

Fixes #667

Thanks:
* John Resig
* John-David Dalton
* Rafaël Blais Masson
* Robert Katić
* Ariel Flesler
cc3eea7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.