当我注册一个新帐户并且一切顺利时,这部分代码将运行并更改表单以显示消息“检查您的电子邮件[...]”。我试图让消息仅显示几秒钟,然后重定向回主页。
_("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
和 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);
关于javascript - 我可以在一段时间间隔(例如 10 秒)后将 innerHTML 文本重定向回我的主页吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26569582/