<script>
  function change(org)
{
 if (org=="A")
{
    document.Myframe.location.href="A.htm";
 }
else
{
     document.Myframe.location.href="B.htm";
  }
}
</script>
<input type=button name="A" value="TestA" onclick=change(this.name);>
<input type=button name="B" value="TestB" onclick=change(this.name);>
<iframe name=Myframe src="tmp.htm"></iframe>

解决方案 »

  1.   

    or..
    <script>
      function change(org)
    {
     if (org.name=="A")
    {
        document.Myframe.location.href="A.htm";
     }
    else
    {
         document.Myframe.location.href="B.htm";
      }
    }
    </script>
    <input type=button name="A" value="TestA" onclick=change(this);>
    <input type=button name="B" value="TestB" onclick=change(this);>
    <iframe name=Myframe src="tmp.htm"></iframe>不能跨域访问..
      

  2.   

    t.htm//请把frame iframe的名字和id都设为Myframe,然后<script>
      function change(org)
    {
     if (org.name=="A")
    {
        document.all.Myframe.src="A.htm";
     }
    else
    {
         document.all.Myframe.src="B.htm";
      }
    }
    </script>
    <input type=button name="A"  value="TestA" onclick=change(this);>
    <input type=button name="B"  value="TestB" onclick=change(this);>
    <iframe name=Myframe src=tmp.htm></iframe>再看看!
      

  3.   

    对于frame和iframe有一个特殊现象,name是指包含在frame里面的网页的window对象。
    <script>
      function change(org)
    {
     if (org.name=="A")
    {
       document.all.Myframe.src="A.htm";//document.Myframe.location.href="A.htm";亦可
     }
    else
    {
        document.all.Myframe.src="B.htm";//document.Myframe.location.href="B.htm";亦可
      }
    }
    </script>
    <input type=button name="A"  value="TestA" onclick=change(this);>
    <input type=button name="B"  value="TestB" onclick=change(this);>
    <iframe name='Myframe' id='Myframe' src=tmp.htm></iframe>