框架中取值問(wèn)題
DEM003.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <frameset rows="70,*" cols="*" framespacing="0" frameborder="yes" style="border:0px"> <frame src="DEMO03_bar.html" name="bar" scrolling="No" noresize="noresize" id="bar"arginwidth="0" marginheight="0" /> <frameset cols="150,*" frameborder="yes" border="1" framespacing="0"> <frame src="DEMO03_menu.html" name="menu" scrolling="No" noresize="noresize" id="menu" marginwidth="0" marginheight="0" /> <frame src="DEMO03_main.html" name="mainFrame" id="main" marginwidth="0" marginheight="0" /> </frameset> </frameset> <noframes><body> </body> </noframes></html>
DEM003_bar.html
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script> //補(bǔ)充完成此函數(shù),用于刷新Menu窗體的頁(yè)面 function flushMenuFrame(){ //top表示頂級(jí)窗口 的 window對(duì)象 window.top.menu.location.href="DEMO03_menu.html"; }
//補(bǔ)充完成此函數(shù),將barText文本框的值寫入到Main窗口的mainText中去。 function writeValueToMainFrame(){ //parent表示 但前窗口的 上級(jí)窗口的 window對(duì)象 window.parent.mainFrame.document.getElementById("mainText").value=document.getElementById("barText").value; } </script>
</head>
<body> <center>BAR頁(yè)面</center> <button onclick="flushMenuFrame();">刷新框架Menu窗口的頁(yè)面</button> Bar頁(yè)面的文本框:<input type="text" id="barText" value="Bar頁(yè)面的值1"><button onclick="writeValueToMainFrame();">向Main窗口寫值</button> </body> </html>
DEMO003_main.html
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> </head>
<body> <center>Main窗體</center> <br><br> Main窗體中的文本框 <input type="text" id="mainText" value="Main頁(yè)面的值2"> </body> </html>
posted on 2008-06-15 04:24 shine_panda 閱讀(78) 評(píng)論(0) 編輯 收藏