js关闭当前页面 刷新另一页面

JavaScript05

js关闭当前页面 刷新另一页面,第1张

你可以用js监测弹出页面的关闭事件,然后刷新父页面就行了

window.onbeforeunload = function() {

    //这里刷新方法有很多,具体要看你的子窗口是怎样出来的

    window.opener.location.reload()

    //parent.location.reload()

    //self.opener.location.reload()

    //window.opener.location.href=window.opener.location.href

}

iframe里面的子页,用parent.location.href = parent.location.reload()如果是window.open 打开就用opener.location.reload()

在父窗体里边写上一个脚本

<script>

function reflash()

{

window.location.href=window.location.href

}

</script>

在关闭子窗体的脚本写

Response.Write("<script>window.close()window.opener.reflash()window.opener=null</script>")

之前我就这么做过的,可能脚本的某个地方写错了,你需要测试一下。