哪位大神幫忙看看,點(diǎn)了按鈕沒反應(yīng),不知道哪里錯了。。
<!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 new=confirm("是否打開網(wǎng)頁");
??????? if(new==true){
??????????? var win=prompt("確定打開網(wǎng)址");
??????? }
??????? if(win!=null){
??????????? window.open(`http://idcbgp.cn`,`_blank`,`width=400,height=500,menubar=no,toolbar=no`)
??????? }
??????? else
??????? {document.write("再見");}
??????? else
??????? {document.write("再見");}}
2018-05-18
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function openWindow() {
var n = confirm("是否打開網(wǎng)頁");
if (n == true) {
var win = prompt("確定打開網(wǎng)址");
if (win != null) {
window.open(`http://idcbgp.cn`, `_blank`, `width=400,height=500,menubar=no,toolbar=no`)
} else {
document.write("再見");
}
} else {
document.write("再見")
}
}
</script>
</head>
<body>
<input name="button" type="button" onClick="openWindow()" value="打開新窗口" />
</body>
</html>
這樣就行了,new是個指定變量有特定用途,最好不要用來自己設(shè)定!
然后你的問題就是多個功能的大括號邏輯有點(diǎn)混亂,所以導(dǎo)致無法運(yùn)行!
2018-05-18
win != null改成win==null,然后彈出來的第二個框中點(diǎn)取消