Home Trouble Redirecting inside a function
Reply: 0

Trouble Redirecting inside a function

user976
1#
user976 Published in May 23, 2018, 4:43 pm

I have a simple animation I found online and modified to fit my needs, but no matter what I try, I cannot get it to redirect after the animation is done. If I remove the setTimeout It redirects immediately without showing the animation. This is my code:

<html>
<head>
<div id="x" style="background-color:rgb(10,10,10)" align="center">
<img src="icon.ico" alt="Icon" height="256px">
</div>
<script>
    var unBlue=105;
    var gEvent=setInterval("toWhite();", 10);
    var redirect=1;
    function toWhite(){
        if(unBlue<200) document.getElementById("x").style.backgroundColor="rgb("+unBlue+",30,30)";
        else clearInterval(gEvent)
        unBlue+=1;
        setTimeout(myFunction, 1000);
        location.redirect("home.html") //doesn't work
    }
</script>
</html>

I'm still getting used to javascript so a full explanation would be much appreciated. Thank you.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.338666 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO