简体   繁体   中英

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>";

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM