Sunday, February 19, 2012

Java Script To Start A File Download Automatically After 30 Seconds Or Page Load

You can initialize automatic downloads after some waiting time. Optionally you may add a count down screen to start download here i am explaining two ways to start download after 30 seconds.You can also add "click here if the download doesn't start automatically" using ordinary links.
In firefox and google chrome it is easy to do this auto download


Code 1 - You may assign waiting time by replacing 30 with  your assigned time in seconds

<html> 
<title> Title of your download page </title>
<meta http-equiv=REFRESH CONTENT="30; url=http://full path of your file"> 
<body> 
 If the download doesn't start automatically<a href="http://full path">click here</a>. 
</body>
</html>


Some browsers are not supporting the above codes so you may use my second code to start download automatically

Code 2 Waiting time is in micro second 100 micro second = 1 second


<script type="text/javascript">
var t=setTimeout("download()",30000)
function download()
{
window.location = 'full path of your file';
}


</script>


Tags : java script to start download automatically after specified time,php code to start download automatically after page load,waiting download in php,ajax download with waiting,java script ,ajax script code to auto download,internet explorer google chrome firefox browsers

No comments:

Post a Comment