0

this is a problem. its not working. im making a timer before redirecting. is any wrong about my code?

     <script>
        var base_url ="https://www.mydomain.com/";
        var redirect = "<?php echo $redirect; ?>";
        var targetURL= base_url.concat(redirect);
        //change the second to start counting down from
        var countdownfrom=9;


        var currentsecond=document.redirect.redirect2.value=countdownfrom+1;
        function countredirect(){
            if (currentsecond!==1){
                currentsecond-=1;
                document.redirect.redirect2.value=currentsecond;
            }
            else{
                window.location=targetURL;
                return;
            }
            setTimeout("countredirect()",1000);
        }

        countredirect();
        //-->
     </script>
Edi G.
  • 2,432
  • 7
  • 24
  • 33
ShelðÔn Alag
  • 367
  • 2
  • 3
  • 12

1 Answers1

0

Try to

<script>
var base_url ="https://www.mydomain.com/";
<?php echo 'var redirect = "'.$redirect.'";'; ?>
..
</script>
jmattheis
  • 10,494
  • 11
  • 46
  • 58