How do I reference a sibling frame with Jquery/Javascript? -
here's 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 want: when right frame (1.html) loads, changes in left frame (nav.html).
the syntax doesn't seem work in second line ($("#nav").contents()...) because when test "#contents" doesn't work either, when change "this".
i believe need access javascript object window.parent.frames[0].document or [1] access frame.
in jquery can put second parameter so:
$("#nav", window.parent.frames[0].document).find("#test").html("selected"); that , when accessing window object on same domain.
Comments
Post a Comment