0

嗨,我有一个使用 javascript 调用的警报框,当有人在警报框上单击“确定”时,我想重定向到 users_signup 页面我该怎么做是这样的?

alert("You need to sign in to be able to vote");
   redirect_to sign_up_url
4

1 回答 1

3
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';
于 2013-07-15T13:17:31.450 回答