我这段代码有问题。。基本上我现在正在做一个网站,当我在访问网站时制作一个确认弹出框时,我进行对话,没问题,但是当它出现时对于“确定”和“取消”按钮,它们都允许访问网站。我想要的是“确定”按钮让用户进入网站,但“取消”按钮关闭选项卡。我该怎么做呢?
这是代码:
<!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>