關于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狂 閱讀(1221) 評論(0)  編輯  收藏 所屬分類: Web

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

          導航

          統計

          常用鏈接

          留言簿(11)

          隨筆分類(48)

          文章分類(29)

          常去逛逛

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 嫩江县| 滨海县| 邳州市| 河南省| 宁国市| 旅游| 克山县| 孟津县| 江津市| 个旧市| 寿阳县| 穆棱市| 阿巴嘎旗| 三门县| 上虞市| 民权县| 陆川县| 龙州县| 洛宁县| 汤原县| 寻甸| 福泉市| 陆丰市| 鸡东县| 沾益县| 十堰市| 牡丹江市| 新津县| 格尔木市| 许昌县| 宽甸| 九江县| 兴海县| 全椒县| 浠水县| 通城县| 大渡口区| 门头沟区| 南城县| 蒙阴县| 普宁市|