javascript - redirect when download is initiated -
The page should be redirected after the start of the download, but I have a code like whether the download is started or not , It is being redirected later. SetTimeout is a solution so that we can start a download or write a condition after the completion, we can redirect to the desired page. Thanks in advance ..
& lt ;? Php while ($ row1 = mysql_fetch_array ($ result)) {$ name = $ row1 ['name']; $ Type = $ ROW1 ['type']; ? & Gt; & Lt; Div class = "rect" id = "d1" & gt; & Lt; Img alt = "bottom-icon" src = "down-drop-icon" align = "left" width = "20" height = "20" /> & Lt; A href = "download.php? Filename = & lt ;? php echo $ name; & gt;" & Gt; & Lt ;? Php echo $ name ;? & Gt; & Lt; / A & gt; & Lt; Script type = "text / javascript" & gt; Var howLongToWait = 15; // var urlOfRedirectLocation Number of seconds to wait = 'http://gomasti.in/p/gomasti/'; Function startRedirect () {window.top.location.href = urlOfRedirect location; } SetTimeout ('startRedirect ()', howLongToWait * 1000); & Lt; / Script & gt; & Lt; / Div & gt; & Lt ;? Php}? & Gt;
When you click on the link, you want to activate the timer: < / P>
& lt; A href = "download.php? Filename = & lt ;? php echo $ name; & gt;" Onclick = "setTimeout ('startrirectirect)', howLongToWait * 1000);" & Gt; & Lt ;? Php echo $ name ;? & Gt; & Lt; / A & gt; while looping & lt; Script & gt; should be the code, define the function and variable only once.
Comments
Post a Comment