情景描述:在父页面点击的时候,通过window.open(url);调转到一页面,
该页面只是实现展示功能。当用户点击子页面的叉的时候,希望刷新父页面。
问题解决:在弹出的子页面中添加监听,如下:
window.οnbefοreunlοad=function checkLeave(e){
var evt = e ? e : (window.event ? window.event : null); //此方法为了在firefox中的兼容
if(e!=evt){
window.opener.location.reload();
}
}
缺点:貌似不能判定是关闭还是刷新。