關(guān)于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測(cè)試</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測(cè)試</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='調(diào)用frame2.htm中的變量和方法' onclick="test1()"><br>
          <input type=button value='調(diào)用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結(jié)束!
          <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測(cè)試</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結(jié)束!
          <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測(cè)試</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='調(diào)用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狂 閱讀(1216) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Web

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(11)

          隨筆分類(lèi)(48)

          文章分類(lèi)(29)

          常去逛逛

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 聂拉木县| 磴口县| 沈丘县| 四子王旗| 平果县| 和顺县| 尉氏县| 安顺市| 龙泉市| 和林格尔县| 南川市| 平武县| 阆中市| 临沂市| 鄂州市| 沧州市| 鹤山市| 天镇县| 凌源市| 桂东县| 乌兰县| 安乡县| 磐安县| 曲靖市| 辽阳市| 依兰县| 安国市| 岢岚县| 贵州省| 奇台县| 清涧县| 闻喜县| 鹰潭市| 礼泉县| 思南县| 孝感市| 齐河县| 中江县| 当涂县| 河北省| 资兴市|