How to access frame (not iframe) contents from jQuery.

Posted by kazanaki on Stack Overflow See other posts from Stack Overflow or by kazanaki
Published on 2010-05-27T14:21:52Z Indexed on 2010/05/27 14:31 UTC
Read the original article Hit count: 198

Filed under:
|
|

Hello

I have 2 frames in one page like this (home.html)

<frameset rows="50%, 50%">
        <frame id="treeContent" src="treeContent.html" />
        <frame id="treeStatus"  src="treeStatus.html" />
</frameset>

and then in one frame (treeStatus.html) I have something like

<body style="margin: 0px">
<div id="statusText">Status bar for Tree</div>
</body>

I want from the top window to manipulate the div located in the child frame via jquery (e.g show and hide).

I have seen several questions like this and they suggest the following

$(document).ready(function(){

            $('#treeStatus').contents().find("statusText").hide();
     });

I do not know if this works with iframes but in my case where I have simple frames it does not seem to work. The code is placed inside home.html

Here is some output from firebug console

>>> $('#treeStatus')
[frame#treeStatus]
>>> $('#treeStatus').contents()
[]
>>> $('#treeStatus').children()
[]

So how do I access frame elements from the top frame? Am I missing something here?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html