[英]How do I make my JavaScript prompt redirect to a different page if the person doesn't qualify
var age = prompt("How old are you??")
if(age < 18)
{
}
else
{
}
I was just wondering how I make this JavaScript code either redirect to a different page or allow the user to continue on the page they clicked, if of aged. 我只是想知道如何使JavaScript代码重新定向到其他页面,或者允许用户继续浏览所单击的页面(如果已老化)。
if(age < 18) {
window.location.href = 'not-old-enough.html';
} else {
// Do nothing
}
if (age < 18) {
window.location.href = 'not-old-enough.html';
} else {
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.