0
下载启动后应该重定向页面,但我有代码是否开始下载,它是在setTimeout之后重定向的。有没有什么解决方案,以便我们可以编写一个条件,如下载开始或完成后,我们可以重定向到所需的页面。在此先感谢..下载启动时重定向
<?php
while($row1=mysql_fetch_array($result))
{
$name=$row1['name'];
$type=$row1['type'];
?>
<div class="rect" id="d1">
<img alt="down-icon" src="down-drop-icon.png" align="left" width="20" height="20" />
<a href="download.php?filename=<?php echo $name ;?>" >
<?php echo $name ;?></a>
<script type="text/javascript">
var howLongToWait = 15; //number of seconds to wait
var urlOfRedirectLocation = 'http://gomasti.in/p/gomasti/';
function startRedirect() {
window.top.location.href = urlOfRedirectLocation;
}
setTimeout('startRedirect()', howLongToWait * 1000);
</script>
</div>
<?php }?>
一个不太优雅的解决方案(对于访问者)是打开一个弹出窗口,该窗口开始下载,之后将自动关闭。然后抓住弹出窗口的关闭事件(非常确定这是可能的),并使用JS重定向。这是Chrome下载页面的做法(至少在某些浏览器中)。 – 2014-10-10 08:56:20
可能有帮助:http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download – ilpaijin 2014-10-10 09:14:31