> I'm trying to reference an element from within an iframe.
> The following normal javascript code works:
>
>      var iframeDoc = window.frames[iframeName].document;
>      var data = iframeDoc.getElementById(iframeElement);
>
> I'm trying to jqueryize the "data" variable as follows 
> (using the actual element id name for the time being):
>
>      var d2 = $("#inside_iframe_element",iframeDoc);
>
> This just yields [], however.  How do I refer to an element within the
iframe?

The #id notation in a selector always uses document.getElementById; in your
case it's the wrong document (the document that contains the iframe, not the
document of the iframe). One workaround would be to select the object
manually when you create the jQuery object,
$(window.frames[iframeName].document.getElementById(iframeElement)), and I
agree it's ugly. Another shorter(text)/longer(runtime) way would be to use
the general attribute syntax, $("[EMAIL PROTECTED], iframeDoc).
If you do the latter, it will be more efficient to use the actual tag type
(e.g, [EMAIL PROTECTED]) rather than *, which requires looking at every element
in the iframe.


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

Reply via email to