惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
罗磊的独立博客
月光博客
月光博客
GbyAI
GbyAI
腾讯CDC
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
雷峰网
雷峰网
B
Blog RSS Feed
美团技术团队
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
D
Docker

博客园 - HenryZhang

Javascript 使用类 用javascript按需加载.js和.css文件 考虑了全半角的SubString javascript小技巧 看完越狱20件必须懂的东西(转) vs2005 安装sp1 NHibernate1.2在VS2005下的配置 AJAX第十一天 AJAX第十天 AJAX第九天 AJAX第七天 AJAX第八天 AJAX第六天 JavaScript常用正则表达式 JS正则表达式问题终于解决 Ajax第五天 Ajax第四天 上传文件时用到的显示文件大小 除去所有在html元素中标记
window.open 打开的窗口关闭后
HenryZhang · 2007-02-07 · via 博客园 - HenryZhang

最近遇到一个问题,要实现window.open打开的窗口关闭后,刷新一下当前页面,原来想的解决办法是在打开的窗口关闭时,window.opener.refresh();,结果一直提示没有权限,可能是和跨域有关吧,在网上搜搜,得到更好的方式,如下:

<script language=javascript>
var timer
var winOpen
function IfWindowClosed() {
if (winOpen.closed == true)
    {
        window.location = window.location;
        window.clearInterval(timer);
    }

}
function btnOpen_Click()
{
winOpen=window.open("2.html","","toolbar=no, location=no, directories=no, status=no, menubar=no" )
timer=window.setInterval("IfWindowClosed()",500);
}

</script>
<input type=button name=btnOpen value=open onclick="btnOpen_Click";>

这里,关键是window.open的时候,要winOpen=window.open,也就是把结果赋一个变量,这样以后就可以根据winOpen.closed判断打开的窗口是否关闭了,
timer=window.setInterval("IfWindowClosed()",500);  表示每隔一定的时间(500)就去执行IfWindowClosed(),当确定已经关闭后,执行window.clearInterval(timer);,将timer清除掉。