注册 登录
编程论坛 JavaScript论坛

检测打开窗口问题?

流浪天边 发布于 2010-12-20 17:22, 579 次点击
程序代码:
//检测打开窗口
<html xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>弹出行为检测</title>
<script language="javascript" >
try{
    var newWin = window.open("http://www.baidu.com","_blanck","width=240",height=180,top=0,
    left=0,scrollbars=no,status=yes,toolbar=no,menubar=no,resizable=no");
    if(!newWin)throw(new Error("弹出窗口被拦截"));
    document.write("新的窗口成功打开");
    }catch(e){
        document.write("打开新窗口检测到一个错误<br>">
        document.write("错误描述为"+e.description+"<br>");
        document.write("<a href=\"javascript:window.open('http://www.baidu.com','_blanck','width=240,height=180,top=0,left=0
        scrollbars=no,status=yes,toolbar=no,menubar=no,resizable=no');void(0);\">单击此处打开新的窗口</a>");
    }

</script>
</head>

<body>
</body>
</html>
大家帮我看看这个地方那里错误!
2 回复
#2
aspic2010-12-21 08:37
程序代码:
<html xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>弹出行为检测</title>
<script language="javascript" >
try{
    var newWin = window.open("http://www.baidu.com","_blanck","width=240,height=180,top=0,left=0,scrollbars=no,status=yes,toolbar=no,menubar=no,resizable=no");
    if(!newWin)throw(new Error("弹出窗口被拦截"));
        document.write("新的窗口成功打开");
    }catch(e){
        document.write("打开新窗口检测到一个错误<br>");
        document.write("错误描述为"+e.description+"<br>");
        document.write("<a href=\"javascript:window.open('http://www.baidu.com','_blanck','width=240,height=180,top=0,left=0,scrollbars=no,status=yes,toolbar=no,menubar=no,resizable=no');void(0);\">单击此处打开新的窗口</a>");
    }

</script>
</head>

<body>
</body>
</html>
自己好好对比吧
#3
流浪天边2010-12-21 21:00
回复 2楼 aspic
谢谢!我会的,也可能是我的粗心造成,但是这编程是我自学的啊!~
1