window.opener 跟 window.parent的区别

window.opener是当前页面A通过open方法弹出一个窗口B,那在B页面上 window.opener就是A

window.parent是当前页面C通过location.href转到新的页面D,那在D页面上window.parent就是B

或者是页面E里套一个frame为F,那F页面的window.parent就是E


A页面通过open方法打开B页面,B页面通过location打开C页面,C页面上刷新A页面

function refreshParenetWindow( refreshMethod ) { switch( refreshMethod ) { case "ButtonClick": oParentButton = window.parent.opener.document.getElementById( "btnSearch" ); oParentButton.click(); break; case "Location": window.opener.navigate(window.opener.location.href); break; default: window.opener.navigate(window.opener.location.href); break; } }

A页面通过open方法打开B页面,B页面通过open打开C页面,C页面上刷新A页面

在B页面的onunload事件中写一段刷新A页面的javascript方法,在C页面关闭的时候,关闭B页面,就可以实现。

你可能感兴趣的:(JavaScript,C++,c,C#,F#)