Marcus
Marcus

Reputation: 425

Can I redirect my innerHTML text back to my home page after an interval of, say 10 secs?

When I sign up for a new account, and everything is successful, this part of the code runs and changes the form to display the message "Check your email[...]". I'm trying to make the message display for only a few seconds, then redirect back to the home page.

_("signupbutton").style.display = "none";
        status.innerHTML = 'please wait ...';
        var ajax = ajaxObj("POST", "signup.php");
        ajax.onreadystatechange = function() {
            if(ajaxReturn(ajax) == true) {
                if(ajax.responseText != "signup_success"){
                    status.innerHTML = ajax.responseText;
                _("signupbutton").style.display = "block";
                }else {
                    window.scrollTo(0,0);
                    _("wrap").innerHTML = "<div >Check your email inbox to complete the sign up process by activating your account.</div>";

Upvotes: 0

Views: 602

Answers (1)

Evil Buck
Evil Buck

Reputation: 1068

as was mentioned in a comment, you only need to use a setTimeout and location

_("signupbutton").style.display = "none";
        status.innerHTML = 'please wait ...';
        var ajax = ajaxObj("POST", "signup.php");
        ajax.onreadystatechange = function() {
            if(ajaxReturn(ajax) == true) {
                if(ajax.responseText != "signup_success"){
                    status.innerHTML = ajax.responseText;
                _("signupbutton").style.display = "block";
                }else {
                    window.scrollTo(0,0);
                    _("wrap").innerHTML = "<div >Check your email inbox to complete the sign up process by activating your account.</div>";
                    setTimeout(function() {
                      window.location = 'homepage.html'; // or whatever the URL is
                    }, 10000);

Upvotes: 1

Related Questions