网页index.htm:
<frameset id="sidebar_content" cols="500px, *" frameborder="1" border="6" framespacing="5" bordercolor="#aaa">
    <frame name="aa" src="aa.htm" scrolling="no" />
    <frame name="bb" src="bb.htm" frameborder="0" />
</frameset>在网页aa里,用js怎么让bb的frame显示百度首页,且aa的frame显示google首页。要求在Firefox和ie下都能用。

解决方案 »

  1.   

    <frameset id="sidebar_content" cols="500px, *" frameborder="1" border="6" framespacing="5" bordercolor="#aaa">
        <frame name="aa" id="aa" src="aa.htm" scrolling="no" />
        <frame name="bb" id="bb" src="bb.htm" frameborder="0" />
    </frameset>
    在aa.htm页加
    <script>
            function gotoUrl() {
                parent.parent.document.getElementById("bb").src = "http://www.baidu.com";
            }
        </script>
    <a href="javascript:gotoUrl()">go</a>
      

  2.   

    window.top.frames['bb'].location.href="http://www.baidu.com";
    location.href="http://www.google.com";
      

  3.   

    正确答案:
    index.html
    <frameset id="sidebar_content" cols="500px, *" frameborder="1" border="6" framespacing="5" bordercolor="#aaa">
        <frame name="aa" src="aa.html" scrolling="no" />
        <frame name="bb" src="bb.html" frameborder="0" />
    </frameset><noframes></noframes>
    aa.html
    <script language="javascript" type="text/javascript">
    function show(){
    window.parent.frames.aa.location.href='http://www.google.com';
    window.parent.frames.bb.location.href='http://www.baidu.com';
    }</script>
    <body onload="show()">
    测试成功~希望楼主给分~
      

  4.   

    <frameset id="sidebar_content" cols="500px, *" frameborder="1" border="6" framespacing="5" bordercolor="#aaa">
        <frame id="aa" src="http://www.google.com.hk/" scrolling="no" />
        <frame id="bb" src="http://www.baidu.com/" frameborder="0" />
    </frameset>js中写:
    document.getElementById("aa").src = "http://www.google.com.hk/";
    document.getElementById("bb").src = "http://www.baidu.com/";
      

  5.   


    <script language="javascript" type="text/javascript">
        function show(){
            window.parent.frames.FrameNames.location.href='http://www.google.com';
            window.parent.frames.FrameNames.location.href='http://www.baidu.com';
        }</script>