我对这段代码有问题..基本上,我现在正在创建一个网站,当我在访问网站时做出确认弹出框时,我会进行对话,没问题,但是当它涉及到“确定”和“取消”按钮,它们都允许访问该网站。我想要的是“确定”按钮,让用户进入网站,但“取消”按钮关闭选项卡。我该怎么做呢?确认框“取消”不起作用?
这是代码:
<!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>
你怎么知道它不工作.. ???你没有提醒任何事情,所以你如何测试它。 –
http://jsfiddle.net/aD6n2/1/ –
它对我来说工作得很好。检查这个http://jsfiddle.net/E43gD/ –