怎么沒(méi)反應(yīng)呢?求大神
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>瀏覽器對(duì)象</title>
?<script type="text/javascript"> ?
??? function openWindon(){
?? ??? ?if(confirm("確定打開(kāi)新窗口嗎?")){
?? ??? ??? ?var url = prompt("請(qǐng)輸入一個(gè)網(wǎng)址","http://idcbgp.cn/");
?? ??? ??? ?window.open( url,"_blank","toolbar=no, menubar=no, scrollbars=yes,? width=400, height=400");
?? ??? ?}
?? ?} ?
?</script>
?
?</head>
?
?<body>
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />
</body>
</html>
2016-10-12
方法名寫錯(cuò)我
2016-10-12
第七行的openWindon改為openWindow
第八行if里面的判斷語(yǔ)句應(yīng)該為confirm("確定打開(kāi)新窗口嗎?")==true
2016-10-12
按鈕的事件是onclick="openWindow()",
你寫的函數(shù)是?function openWindon(),window寫錯(cuò)了,
而且url不給個(gè)if判定的話,無(wú)論prompt界面消息框點(diǎn)的是確定還是取消都會(huì)在新網(wǎng)頁(yè)打開(kāi)慕課網(wǎng),
就是說(shuō)加個(gè)if(url!=null);
2016-10-12
function openwindow(){}
2016-10-12
首先 你的? ? function openWindon()方法與onclick="openWindow()中的window拼寫不一樣,其次你缺少了判斷你打開(kāi)的那個(gè)網(wǎng)頁(yè)是否為空的語(yǔ)句。