有三个页面如下所示
dairyManage.php中嵌套了两个页面,结构如下:
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
  <tr>
    <td width="173" id="frmTitle" noWrap name="fmTitle" align="center" valign="top">
    <iframe name="dmenu" height="100%" width="180" src="dairyMenu.php" border="0" frameborder="0" scrolling="no">
    浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></td>
    <td align="center" valign="top"><iframe name="dmain" height="100%" width="100%" border="0" frameborder="0" src="dairyMain.php"> 浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></td>
  </tr>
</table>我在dairyMain.php页面中,弹出一个新窗口(enterPassword.php),在enterPassword.php中输入值以后,需要将这个页面提交到dairyMain.php进行处理,也就是action指向dairyMain.php,我现在不知道如何将子窗口(enterPassword.php)关闭的同时,将值提交到框架中父窗口(dairyMain.php)
dairyMain.php中的主要代码为
<SCRIPT LANGUAGE="JavaScript">
<!--
function openWin() 

     strFeatures="dialogWidth=300px;dialogHeight=100px;center=yes;middle=yes ;help=no;status=no;scroll=no"; 
     var url,strReturn; 
     url="enterPassword.php?day=<?=$rs['d_date']?>"; 
     strReturn=window.showModalDialog(url,'',strFeatures);   
}
//-->
</SCRIPT>
<?
if($v_is_lock == "1"){
    echo "<script language=\"javascript\">";
    echo "if(confirm('此文章已经加密!\"确定\"输入密码解密,\"取消\"查看加密文章!'))";
    echo "{";
    echo "openWin();";
    echo "}";
    echo "</script>";
}
?>enterPassword.php页面的主要代码为:
<script language="javascript">
function checkPas(){
    if(document.theForm.password.value == ""){
        alert("请输入密码");
        document.theForm.password.focus();
        return false;
    }
    
    //这里的代码不会写,要实现将这个页面的action提交到框架中的dairyMain.php页面处理,同时关闭当前窗口,刷新框架中的dairyMain.php
}
</script>
<div></div>
<div class="STYLE1">
<form name="theForm" method="post" action="">
请输入密码:<input type="password" name="password">
<input type="button" value="确认" onclick="checkPas();">
</form>
</div>主要是中间有框架,所以不大会写,忘高手指点!小弟再此先行谢过!

解决方案 »

  1.   

    子页面可以给父页面传值.
    给你两个页面a.html(父页)<script>
         function  getLink(){window.open("b.html","newindow","width=400,height=200,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes,status=yes'");}
    function  getNewLinkValue(value){
       document.getElementById("adf").value=value;//可以得到子页面设的值
    }</script>
    <textarea cols="60" rows="10" id="adf"></textarea>
    <input  type="button"  value="测试子页面调用"  onclick="getLink();"/>b.html(子页)<script>
         function  setNewLinkValue(){  
            window.opener.getNewLinkValue(document.getElementById("afdf").value);
          }
    </script>
    <textarea cols="60" rows="10" id="afdf" onkeypress="setNewLinkValue()" onblur="setNewLinkValue()" onchange="setNewLinkValue()" onfocus="setNewLinkValue()"></textarea>
    <br />
    <label>
    <input type="submit" name="Submit" value="提交" onclick="setNewLinkValue()"/>
    </label>