0
嗨我有一個警告框,使用javascript調用時,我想重定向到users_signup頁面,當有人單擊確定警告框時,我該如何做到這一點?Javascript從警報框中重定向
alert("You need to sign in to be able to vote");
redirect_to sign_up_url
嗨我有一個警告框,使用javascript調用時,我想重定向到users_signup頁面,當有人單擊確定警告框時,我該如何做到這一點?Javascript從警報框中重定向
alert("You need to sign in to be able to vote");
redirect_to sign_up_url
if (confirm("You need to sign in to be able to vote")){
// They have clicked OK
window.location = 'http://website.com/sign_up_url';
}
或者強制重定向的警告框已經彈出後:
alert("You need to sign in to be able to vote");
// The code execution won't proceed until they click OK
window.location = 'http://website.com/sign_up_url';
感謝有你,只有一個警告框,因爲我不想做一個方式他們有選擇點擊取消,並保持在當前頁 – user2527785
@ user2527785是的,我已經添加到我的回答 – Jon
完美謝謝你 – user2527785