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