為什么我的代碼點擊按鈕無反應,還有函數命名問題
<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>Document</title>
<script?type="text/javascript">
function?Wopen()?{
var?open=confirm("確定打開?");
if?(open==true)?{
var?url=prompt("打開新窗口?","http://www.xianlaiwan.cn");
if?(url!=null)?{
window.open(url,"http://www.xianlaiwan.cn","_blank","width=400px,height=500px,menubai=no,toolbar=no");
}
else?{
alert("goodbye");
}
}?else?{
alert("goodbye");
}
</script>
</head>
<body>
<input?name="button"?type="button"?onclick="Wopen"?value="打開新窗口"/>
</body>
</html>如題,自己也找不到錯誤。
代碼中的Wopen open url 是唯一指定的名字還是可以替換,或者是隨便怎么命名都可以。
之前我做打開窗口練習的時候,函數名命名為Wopen才有效果,隨便起個名字怎么試都不行。
百度也搜不到相關內容。
求大神講解一下里邊規則或者貼個博客地址。
2016-04-02
?明顯少了一個大括號
2016-03-31
window.open(url,"http://www.xianlaiwan.cn","_blank","width=400px,height=500px,menubai=no,toolbar=no");
改為
window.open(url,"_blank","width=400px,height=500px,menubai=no,toolbar=no");
試試?
2016-03-31
onclick="Wopen" 應該是onclick="Wopen()"