0
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.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
  • 2
    Welcome to [so]. This seems to be the same question as [How can I make a redirect page in jQuery/JavaScript?](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript) – Qantas 94 Heavy Aug 14 '14 at 04:38

2 Answers2

2
if(age < 18) {
    window.location.href = 'not-old-enough.html';
} else {
    // Do nothing
}
Blake A. Nichols
  • 870
  • 1
  • 6
  • 11
0
if (age < 18) {
    window.location.href = 'not-old-enough.html';
} else {
    return false;
}
infused
  • 24,000
  • 13
  • 68
  • 78
user3459464
  • 224
  • 1
  • 3