在另一个框架中选择选项后重新加载框架
问题描述:
我在子文件夹/子文件夹中有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)有什么变化?
答
于是我找到解决办法:
这是太简单了......只是改变平变化的行动选择菜单:
onchange="window.open(this.options[this.selectedIndex].value, 'nameOfTargetFrame')"
和删除整个* MM_jumpMenu *代码。感谢提示,我不会发现它没有他们:)
答
首先你不使用iframe,你使用旧的fasion框架。然而,
在您的形式处理选择菜单,你必须设置目标属性是你要在其中打开的位置框架的名称,具体如下:
<form action="" name="form" id="form" target="main_iframe">
你必须选择目标适合您要打开它的窗口名称。即main_iframe或其他任何东西。
你应该为帧设置'id'并将'parent'改为top.document.getElementById('__ frame_id')。在MM_jumpMenu()中,你应该将eval(targ +“。location ='”+ selObj.options [selObj.selectedIndex] .value +“'”)改为targ.src = selObj.options [selObj.selectedIndex] .value; –