<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>window对象</title>
<script type="text/javascript">
var string = confirm("欢迎来到慕课网");
function new_page(){
if(string==true)
{
window.open("http://www.hao123.com","_blank","height=400px,width:600px");
}
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我,打开新窗口" onfocus="new_page()" />
</form>
</body>
</html>
因为你这里用了onfocus,意思是只要焦点在这个button上;当你click后,焦点就会一直 在button上,除非你在文档空白处随便点一下,取消焦点,它才不会一直打开窗口