我的代碼哪里錯了?
CSS代碼:
<script type="text/javascript">
? function BWopen(){
? ? ? var message=confirm("確定打開慕課網嗎?");
? ? ? if(message==ture)
? ? ? {
? ? ? ? ? window.open("http://www.xianlaiwan.cn","_blank","width=600,height=400,top=100,left=0")
? ? ? }
? ? ? else
? ? ? {
? ? ? ? ? alert("打開失??!");
? ? ? }
? }
</script>
HTML代碼:
<body>
? <form>
? ? <input type="button" onClick="BWopen()" value="點擊我,在新窗口顯示目標網頁!" />
? </form>
</body>
彈出確認對話框后,選擇確定不會跳出網頁,選擇取消也不會跳出警告對話框,不知道哪里錯了。我是chrome瀏覽器。
2016-05-31
這里沒加分號。
2016-05-31
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
? function Wopen(){
? ? ? window.open('http:www.xianlaiwan.cn','_blank','width=600,height=400,top=100,left=0')
? }?
</script>
</head>
<body>
? ? <input name="button" type="button" onClick="Wopen()" value="點擊我,打開新窗口!" / >
</body>
</html>
2016-05-31
window.open("http://www.xianlaiwan.cn","_blank","width=600,height=400,top=100,left=0")括號里面應該是單引號而不是雙引號