js收集
1.关闭窗口或返回上一页
function CloseWin() {
if (window.opener) {
window.opener = null;
window.open('', '_self');
window.close();
}
else {
window.history.go(-1);
}
}
2.在A窗口中打开B窗口,在B窗口中操作完以后关闭B窗口,同时自动刷新A窗口
B
function closeWin(){
hasClosed = true;
window.opener.location="javascript:reloadPage();";
window.opener=null;
window.close();
}
function window.onbeforeunload(){
if(!hasClosed){//如果已经执行了closeWin方法,则不执行本方法
window.opener.location="javascript:reloadPage();";
}
}
A
reloadPage方法如下:
function reloadPage() {
history.go(0);
document.execCommand("refresh")
document.location = document.location;
document.location.reload();
}

浙公网安备 33010602011771号