2012-12-18 44 views
3

我在子文件夾/子文件夾中有PHP頁面。 在根中我有兩個文件:index.html和demo.html。在另一個框架中選擇選項後重新加載框架

demo.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 
<html> 
<head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf8" /> 
    <meta name="description" content="" /> 
    <meta name="keywords" content="" /> 
    <script language="JavaScript" type="text/JavaScript"> 
    <!-- 
    function MM_jumpMenu(targ,selObj,restore){ //v3.0 
     eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 
     if (restore) selObj.selectedIndex=0; 
    } 
    //--> 
    </script> 
</head> 
<body> 
    <div id="demo_wrapper"> 
     <div id="themeslist"> 
      <form action="" name="form" id="form"> 
       <select name="select" onChange="MM_jumpMenu('parent',this,1)"> 
        <option value="#">Select Theme</option> 
        <option value="http://127.0.0.1/themes/index.php?theme=1">Theme1</option> 
        <option value="http://127.0.0.1/themes/index.php?theme=3">Theme2</option> 
       </select> 
      </form> 
     </div> 
    </div> 
</body> 
</html> 

和index.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> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf8" /> 
    <meta name="description" content="" /> 
    <meta name="keywords" content="" /> 
</head> 
    <frameset rows="100,*" framespacing="0" frameborder="no" border="0"> 
     <frame src="http://127.0.0.1/demo.html" name="head_frame" scrolling="no" noresize="noresize" id="head_frame" title="head_frame" /> 
     <frame src="http://127.0.0.1/themes/index.php" name="main_iframe" id="main_iframe" title="main_iframe" /> 
    </frameset> 
<noframes> 
<p>Your browser does not handle frames!</p> 
</noframes> 
</html> 

來源:http://www.entheosweb.com/website_design/jump_menus.asp

現在的問題是,當我在菜單中選擇選項 - 它重新加載整個頁面和框架dissapear。 只重新加載選定的幀(main_iframe)有什麼變化?

+0

你應該爲幀設置'id'並將'parent'改爲top.document.getElementById('__ frame_id')。在MM_jumpMenu()中,你應該將eval(targ +「。location ='」+ selObj.options [selObj.selectedIndex] .value +「'」)改爲targ.src = selObj.options [selObj.selectedIndex] .value; –

回答

0

於是我找到解決辦法:

這是太簡單了......只是改變平變化的行動選擇菜單:

onchange="window.open(this.options[this.selectedIndex].value, 'nameOfTargetFrame')" 

和刪除整個* MM_jumpMenu *代碼。感謝提示,我不會發現它沒有他們:)

0

首先你不使用iframe,你使用舊的fasion框架。然而,

在您的形式處理選擇菜單,你必須設置目標屬性是你要在其中打開的位置框架的名稱,具體如下:

<form action="" name="form" id="form" target="main_iframe"> 

你必須選擇目標適合您要打開它的窗口名稱。即main_iframe或其他任何東西。