【发布时间】:2016-03-16 20:36:09
【问题描述】:
我有一个 .php 文件正在运行,它正在生成一个可下载的文件;当 .php 文件运行时,它会在浏览器中打开一个选项卡。根据创建文件的条件,有时 .php 文件最多需要 15 秒。
我想知道此选项卡何时打开并生成可下载文件,何时关闭。这样我可以在生成文件时显示某种加载消息。当 .php 文件完成创建文件后,它会自动关闭选项卡。
代码:
var win = window.open(download, '_blank'); //opens the php file which generates the file.
if (win)
{
win.focus();
//have some sort of message stating to wait for the file to download here and then close it when the php file finishes running.
}
else
{
alert("Please allow popups.");
}
closePopup2();
【问题讨论】:
-
试试 win.document.write("")
-
这似乎不起作用。
标签: javascript window focus detect