- 问题内容:window.opener.location.reload()的使用,大家帮忙啊
- 原讨论链接:http://community.csdn.net/expert/topicview1.asp?id=1685384
- 所属论坛:JavaScript 审核组:WEB开发
- 提问者:sdsugar 解决者:fason
- 感谢:Estyle、xinyunyishui、fason
- 关键字:
- 答案:
我的score.php是用来显示数据的,其中有这么一个按钮:
<input type=button name=edit value=添加 οnclick=javascript:window.open('scoreadd.php?,'_blank','width=600,height=350,top=150,left=250','toolbar=no,menubar=no,scrollbars=yes')>
scoreadd.php是用来添加按钮的。
里面有这么一个FROM:
<form name=scoreadd action="scoreadd.php?bjscore_tbname=<?echo $bjscore_tablename;?>&bjstu_tablename=<?echo $bjstu_tablename;?>" method=post οnsubmit="return userconfirm(this)" οnclick="window.opener.location.reload()">
成绩:<input name=score οnfοcus=this.select() onMouseOver=this.focus()></input>
排名:<input name=paiming οnfοcus=this.select() onMouseOver=this.focus()></input>
<input type=submit value=确定 >
<input type=reset value=重写>
</form>
<script>
function userconfirm(f)
{
var s="学号:"+f.stuname.value+"/n成绩:"+f.score.value+"/n排名:"+f.paiming.value+"/n确认要添加吗?"
if(confirm(s)) return true
return false
}
οnclick="window.opener.location.reload()"一句当然是为了让父窗口刷新的。
οnsubmit="return userconfirm(this)"是为了在提交之前弹出一个确定的消息框。
现在问题是,如果按照上面的代码把οnclick="window.opener.location.reload()"放在FORM里,那么不等你确定那个消息框,父窗口就已经在添加数据之前刷新了。该怎么办呢。我后来把window.opener.location.reload()放到function里面,即:
<script>
function userconfirm(f)
{
var s="学号:"+f.stuname.value+"/n成绩:"+f.score.value+"/n排名:"+f.paiming.value+"/n确认要添加吗?"
if(confirm(s))
{window.opener.location.reload()
return true
} //或者两句的顺序换一下
return false
}
</script>
可是这样还是不行。高手请指教啊!!!谢谢了
---------------------------------------------------------------
{
window.opener.location.reload();
return true;
}
最明显的错误就是你没有加分号!你先改改,看还有没有错误!
---------------------------------------------------------------
你要通过页面处理表单的吧?
php:
<?……//这里是你的表单处理程序
echo "<script>opener.location.reload()</script>";
?>
asp:
<%……'这里是你的表单处理程序
response.write "<script>opener.location.reload()</script>"
%>
---------------------------------------------------------------
去掉οnclick="window.opener.location.reload()"
在新打开的一页中
<body οnlοad="window.opener.location.reload()">
window.opener.location.reload()的使用
最新推荐文章于 2022-09-16 08:40:26 发布