请问Chrome下onbeforeunload函数中confrim无效的问题
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button!");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
}
onbeforeunload=function(){
show_confirm()
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Show a confirm box" />
</body>
</html>
我想在onbeforeunload函数中添加一个confirm函数,在ie下有效,为什么在chrome下没有效果,怎么才能让他生效啊,谢谢