運(yùn)行不出來(lái)
?<script type="text/javascript">?
?function my(){
var a=confirm("是否打開(kāi)新網(wǎng)頁(yè)?");
if(a==true){ var b=prompt("http://idcbgp.cn/");}
?if(b!=null){window.open('http://idcbgp.cn',width=400,height=500
,menubar=no,toolbar=0;);}
? else
{alert("結(jié)束 ");}
?</script>?
?</head>??<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="my()" />?
</body></html>
直接懵掉了,請(qǐng)求大神指點(diǎn)
2017-04-07
或者把你的代碼改成這樣,記住window.open 函數(shù),設(shè)置窗口屬性的參數(shù)是有引號(hào)的
<script type="text/javascript">
? ?function my(){
? ? ? ?var a=confirm("是否打開(kāi)新網(wǎng)頁(yè)?");
? ? ? ?var b;
? ? ? ?if(a==true){
? ? ? ? ? ?b=prompt("http://idcbgp.cn/");
? ? ? ?}
? ? ? ?if(b!=null){
? ? ? ? ? ?window.open('http://idcbgp.cn',"width=400,height=500,menubar=no,toolbar=0");
? ? ? ?} else {
? ? ? ? ? ?alert("結(jié)束 ");
? ? ? ?}
? ? ? ?}
</script>
</head> ?<body>
<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="my()" />
</body></html>
2017-04-07
不知道你要干嘛,是要判斷用戶(hù)輸入打開(kāi)一個(gè)新的窗口嗎?
<script type="text/javascript">?
?function my(){
var a=confirm("是否打開(kāi)新網(wǎng)頁(yè)?"); ?//詢(xún)問(wèn)是否要打開(kāi)窗口
if(a){?
????//a 的返回值只要兩種結(jié)果true flase ?,直接使用就可以
?????var b=prompt("http://idcbgp.cn/");? ? ??
? ? ? if(b!=null){
????????//不管輸入什么內(nèi)容,只要有輸入就打開(kāi)下面的地址
? ? ? ? window.open('http://idcbgp.cn',width=400,height=500,menubar=no,toolbar=0);
? ? ? }else{
? ? ?//如果b的值為null ,用戶(hù)什么也沒(méi)有輸入
???? alert("結(jié)束");?
? ? ?}
}else{
????alert("結(jié)束");
}
?</script>?
?</head>??<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="my()" />?
</body></html>
2017-04-07
<script type="text/javascript">?
?function my(){
var a=confirm("是否打開(kāi)新網(wǎng)頁(yè)?");
if(a==true){ var b=prompt("http://idcbgp.cn/");
?if(b!=null){window.open('http://idcbgp.cn',width=400,height=500
,menubar=no,toolbar=0);}
? else
{alert("結(jié)束 ");}
}else{
alert("結(jié)束");}
?</script>?
?</head>??<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="my()" />?
</body></html>
2017-04-07
你把邏輯整錯(cuò)了,if語(yǔ)句中嵌套了ifelse語(yǔ)句的,你仔細(xì)檢查一下。