I'm having problems with this code.. Basically, I'm making a website right now, and when I'm making a Confirm pop-up box when visiting the website, I make the dialogue, no problem, but when it comes to the "Ok" and "Cancel" buttons, they both allow access into the website. What I want is for the "Ok" button to proceed the user into the site, but the "Cancel" button to close the tab. How do I do this?
This is the code:
<!doctype html>
<html>
<head>
<script>
var r=confirm("If you agree you are at least 18 Years of Age, press Ok. Otherwise, press Cancel.");
if (r==true) {
x="You pressed OK!";
}
else {
x="You pressed Cancel!";
}
</script>
</head>
</html>