javascript - redirect when download is initiated -
javascript - redirect when download is initiated -
page should redirected after download starts, have code whether download start or not, redirecting after settimeout. there solution can write status after download start or finish , can redirect desired page. in advance..
<?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 wait var urlofredirectlocation = 'http://gomasti.in/p/gomasti/'; function startredirect() { window.top.location.href = urlofredirectlocation; } settimeout('startredirect()', howlongtowait * 1000); </script> </div> <?php }?>
you want activate timer when user clicks link:
<a href="download.php?filename=<?php echo $name ;?>" onclick="settimeout('startredirect()', howlongtowait * 1000);"><?php echo $name ;?></a> the <script> code needs before while loop, define function , variable once.
javascript php
Comments
Post a Comment