1

Here's my main index.html:

<frameset cols="200,*" border="0" frameborder="0" framespacing="0">
    <frame name="nav" id="nav" src="nav.html" />
    <frame name="content" id="content" src="1.html" />
</frameset>

Here's nav.html:

<body>
    <ul>
        <li><a href="1.html" target="content" id="test">1</a></li>
        <li><a href="2.html" target="content">2</a></li>
    </ul>
</body>

Here's 1.html:

<body>    
<script type="text/javascript">
    $("#content").ready(function() {
         $("#nav").contents().find('#test').html('selected');
    } );
</script>
</body>

What I want: When the right frame (1.html) loads, it changes something in the left frame (nav.html).

The syntax doesn't seem to work in the second line ($("#nav").contents()...) because when I test it with "#contents" it doesn't work either, but does when I change it to "this".

1 Answer 1

1

I believe you need to access the javascript object window.parent.frames[0].document or [1] to access your frame.

In jquery you can put this as a second parameter so:

$("#nav", window.parent.frames[0].document).find("#test").html("selected");

That is and only is when you are accessing the window object on the same domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.