這為什么輸出不出來(lái)
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
function openWindow(){
var th=confirm("是否打開(kāi)網(wǎng)頁(yè)");
// 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
if(th==true){
var zh=prompt("請(qǐng)輸入網(wǎng)址";"www.baidu.com");
// 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
if(zh!=null){
window.open(zh,"_blank",'width=400px,height=500px,menubar=no,toolbar=no')
}
?//打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
else{alert("ok")}
}
? ? else{alert("ok")}
? ?
??
? ?}?
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-04-19
prompt消息對(duì)話框中間的傳倆個(gè)參數(shù)的話,格式是逗號(hào)而不是分號(hào),還有個(gè)是通過(guò)open打開(kāi)網(wǎng)站時(shí),網(wǎng)址前需要加http://,因?yàn)閔ttp是超文本傳輸協(xié)議。