求指點哪錯了?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
? <script type="text/javascript">
? function chi(){
? ? ?var flag=confirm("是否打開百度?");
? ? ?if(flag)
? ? ?{
? ? ? ? ?window.open('http://www.baidu.com','_blank')
? ? ?}
?</script>
</head>
<body>
<input type="button" name="button" value="anniu" onClick="chi()"/>
</body>
</html>
2017-05-27
少一個 }
2017-05-27
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
? <script type="text/javascript">
? function chi(){
? ? ?var flag=confirm("是否打開百度?");
? ? ?if(flag)
? ? ?{
? ? ? ? ?window.open('http://www.baidu.com','_blank')
? ? ?}
}
?</script>
</head>
<body>
<input type="button" name="button" value="anniu" onClick="chi()"/>
</body>
</html>
大神,你的上面的</javascript>上面少一個大括號了
2017-05-27
少一個 }
2017-05-27
? ? ?window.open('http://www.baidu.com','_blank')
? ? ?}
在"}后面再加一個"}",保證function()方法的作用區(qū)域完整,內(nèi)部的條件才會執(zhí)行!