關于Frame的取值

          testFrame.htm
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>frame測試</title>
          </head>

          <frameset rows="390,*" frameborder="NO" border="0" framespacing="0">
            
          <frame src="frame1.htm" name="topFrame" scrolling="NO" noresize >
            
          <frame src="frame2.htm" name="mainFrame">
          </frameset>
          <noframes><body>
          </body></noframes>
          </html>
          frame1.htm
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd"
          >
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>frame測試</title>
          <script>
          function test1()
          {
            alert(parent.mainFrame.frame2Variable);
            parent.mainFrame.frame2Method();
            alert(parent.mainFrame.document.getElementById('frame2FormValue').value)
          }

          function test2()
          {
            alert(window.frames['iframe'].iframeVariable);
            window.frames['iframe'].iframeMethod();
            alert(window.frames['iframe'].document.getElementById('iframeFormValue').value)
          }

          </script>
          </head>

          <body>
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          <br>
          frame1.htm!
          <br>
          <form name='frame2Form'>
          <input type=button value='調用frame2.htm中的變量和方法' onclick="test1()"><br>
          <input type=button value='調用iframe.htm中的變量和方法' onclick="test2()"><br>
          <input type=text id='frame1FormValue' value='frame1.htm中的表單元素的值' ><br>
          </form>
          <br>
          這是frame1.htm中的IFrame
          <br>
          <Iframe name='iframe' src='iframe.htm' width='800' height="600"/><br>

          frame1.htm結束!
          <br>
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          <br>
          </body>
          </html>
          frame2.htm
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd"
          >
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>frame測試</title>
          <script>
          var frame2Variable='frame2.htm中的變量!';
          function frame2Method()
          {
          alert('frame2.htm中的方法!');
          }

          </script>
          </head>

          <body>
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          <br>
          frame2.htm!
          <br>
          <form name='frame2Form'>
          <input type=text id='frame2FormValue' value='frame2.htm中的表單元素的值' >
          </form>
          frame2.htm結束!
          <br>
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          <br>
          </body>    
          </html>
          iframe.htm
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd"
          >
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>frame測試</title>
          <script>
          var iframeVariable='iframe.htm中的變量!';
          function iframeMethod()
          {
          alert('iframe.htm中的方法!');
          }

          function parentMethod()
          {
          parent.test1();
          parent.test2();
          }

          function parentFormValue()
          {
          alert(parent.document.getElementById('frame1FormValue').value);
          }

          </script>
          </head>

          <body>
          <form name='iframeForm'>
          <input type=text id='iframeFormValue' value='iframe.htm中的表單元素的值' >
          <input type=button  value='調用frame1.htm中的方法' onclick='parentMethod()'>
          <input type=button  value='輸出frame1.htm中的表單元素' onclick='parentFormValue()'>
          </form>
          Iframe的frame!

          </body>
          </html>



          posted on 2007-09-26 13:28 我為J狂 閱讀(1220) 評論(0)  編輯  收藏 所屬分類: Web

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          常用鏈接

          留言簿(11)

          隨筆分類(48)

          文章分類(29)

          常去逛逛

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 玛纳斯县| 普格县| 昌黎县| 神农架林区| 九台市| 遂昌县| 定西市| 桑植县| 嘉荫县| 神农架林区| 枣阳市| 鄢陵县| 将乐县| 梧州市| 大悟县| 阳信县| 诸城市| 桃江县| 阿荣旗| 栖霞市| 大邑县| 株洲县| 安达市| 吉林省| 疏勒县| 渝中区| 闸北区| 衡山县| 尉犁县| 永川市| 大同市| 旬邑县| 洪泽县| 两当县| 巩义市| 鱼台县| 丹寨县| 偏关县| 岳阳县| 恩施市| 安丘市|