js 关闭子窗体时如何刷新父窗体

JavaScript011

js 关闭子窗体时如何刷新父窗体,第1张

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

<script>

function reflash()

{

window.location.href=window.location.href

}

</script>

在关闭子窗体的脚本写

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

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

如果子窗体存在window.opener,可以尝试下面方法

父窗体里写一个函数:

window.closeThisWindow = function(){

window.close()// 或者 this.close()

}

然后在打开的子窗体或iframe里事件里写:

window.opener.closeThisWindow()

试试 ,可能可以!

chrome的showModalDialog方法很像执行了window.open方法,那么我们可以利用window.opener来实现window.returnValue的功能。

父窗体部分js代码:

returnValue = window.showModalDialog("son.html ", window)

//for chrome if (returnValue == undefined) { returnValue = window.returnValue }

子窗体部分js代码:

if (window.opener != undefined) { //for chrome window.opener.returnValue = "opener returnValue" } else { window.returnValue = "window returnValue" } window.close() 这样也在IE,FireFox,Chrome,Safari等浏览器下都可以通用了。