> I have a quandary. I open an iframe with some arbitrary 
> content in it. I want to be able to click on something within 
> the iframe to cause the iframe (and the div tag that contains 
> the iframe) to go away. I am having trouble getting to the 
> iframe. I know it's possible as I've seen it elsewhere, I 
> just can't find the proper path to it.
> 
> I basically have this structure:
> 
> <html>
>       <body>
>               <div>
>                       <iframe>
>                               <html>
>                                       <body>
>                                               <any tag>
>                                       </body>
>                               </html>
>                       </iframe>
>               </div>
>       </body>
> </html>
> 
> It's not exactly accurate but it gives a good idea what I'm 
> looking to do
> 
> I've tried:
> 
> // This should as far as I can get to the div tag which is 
> where I want to be $('#any tag').parents('html').parent().parent();
> 
> But when I alert the length of this, I get 0. I've also tried 
> a pure DOM way any_tag.ownerDocument.parent.parent.parent
> but again, I get nothing.

You're mixing up two different kinds of "parents" - parent *node/element*
and parent *window*.

Assuming that anyTag is a valid reference to your <any tag>, then this code
should work (it's based on tested code that I use):

  var frameDoc = anyTag.ownerDocument;
  var frameWindow = frameDoc.parentWindow || frameDoc.defaultView;
  var frameElement = frameWindow.frameElement;
  var outerDiv = frameElement.parentNode;

-Mike


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to