子窗口访问父窗口里的框架
分别是test.html,ifr.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>子框架访问父框架</title> </head> <frameset cols="240,*" name="btFrame" frameborder="NO" border="0" framespacing="0"> <frame src="ifr.html" name="menu" id="menu" scrolling="yes" /> <frame src="http://www.so.com" name="main" id="main" scrolling="yes" /> </frameset> <noframes> <body>你的浏览器不支持框架!</body> </noframes> </html>
<html> <head> <script type="text/javascript" src="jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ //parent.document.getElementById("main").src="http://www.baidu.com/"; //JS版 $("#main", parent.document).attr("src","http://www.baidu.com/"); }); }); </script> </head> <body> <button type="button">Click me</button> </body> </html>