我的代碼哪里錯(cuò)了?
CSS代碼:
<script type="text/javascript">
? function BWopen(){
? ? ? var message=confirm("確定打開慕課網(wǎng)嗎?");
? ? ? if(message==ture)
? ? ? {
? ? ? ? ? window.open("http://idcbgp.cn","_blank","width=600,height=400,top=100,left=0")
? ? ? }
? ? ? else
? ? ? {
? ? ? ? ? alert("打開失??!");
? ? ? }
? }
</script>
HTML代碼:
<body>
? <form>
? ? <input type="button" onClick="BWopen()" value="點(diǎn)擊我,在新窗口顯示目標(biāo)網(wǎng)頁!" />
? </form>
</body>
彈出確認(rèn)對話框后,選擇確定不會跳出網(wǎng)頁,選擇取消也不會跳出警告對話框,不知道哪里錯(cuò)了。我是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:idcbgp.cn','_blank','width=600,height=400,top=100,left=0')
? }?
</script>
</head>
<body>
? ? <input name="button" type="button" onClick="Wopen()" value="點(diǎn)擊我,打開新窗口!" / >
</body>
</html>
2016-05-31
window.open("http://idcbgp.cn","_blank","width=600,height=400,top=100,left=0")括號里面應(yīng)該是單引號而不是雙引號