大佬幫忙看一下,最后的默認窗口打不開
function openWindow(){
? ? ? ? var open=confirm("是否打開窗口");
? ? ? ? if(open==true){
? ? ? ? ? ?document.write(magss);
? ? ? ? }else{
? ? ? ? ? ? open.close();
? ? ? ? }
? ? ? ? var magss=prompt("確定打開的網(wǎng)址,默認為 http://idcbgp.cn/")
? ? ? ? if(magess==""){
? ? ? ? ? ? ?window.close();
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ??
? ? ? ? ? ? window.write(pad);
? ? ? ? }
? ? ? ?function pad(){
? ? ? ? window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');}
? ? }
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
2019-07-22
大兄弟給個采納回答吧
2019-07-22
噢噢感謝大佬;?
2019-07-22
function openWindow() {
var open = confirm("是否打開窗口");
var magss = prompt("確定打開的網(wǎng)址,默認為 http://idcbgp.cn/")
if (magss == "") {
pad()
}else {
window.open(magss, '_userUrl', 'width=400,height=500,menubar=no,toolbar=no');
}
function pad() {
window.open('http://idcbgp.cn/', '_blank', 'width=400,height=500,menubar=no,toolbar=no');
}
}
第一個調用默認打開的方法是調用函數(shù)就可以了? pad()
第二個如果為空 就打開默認,不為空就打開用戶輸入的,你的邏輯寫反了