confirm消息確認(rèn)
?function Wopen(){
? ? var xinbox=confirm("是否新建窗口?");
? ? if(xinbox==true)
? ? {
? ? ? ? var ttcaa=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
? ? ? ? if(ttcaa=="http://idcbgp.cn"){ ? ?
? ? ? ? ? ? window.open(ttcaa,'_blank','width=600,height=500,left=100,top=100')
? ? ? ? }
? ? ? ? else{
? ? ? ? alert("你為啥不打開慕課網(wǎng)?");
? ? ? ? }
? ? }
? ? else{
? ? ? ? alert("你沒有打開窗口!");
? ? }
}
這個運行是否開新窗口,我點擊取消,可還是讓我輸入網(wǎng)址的
2017-03-10
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>confirm</title>
?<script type="text/javascript">
?function Wopen()
?{
? ? ?var mychar =confirm("是要打開新的窗口嗎");
? if(mychar==true)
? {
? ? ? var ttcaa=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
? ? ? document.write(ttcaa);
? ? ? ?if(ttcaa=="http://idcbgp.cn"){ ? ?
? ? ? ? ? ? window.open(ttcaa,'_blank','width=600,height=500,left=100,top=100')
? ? ? ? }
? ? ? ? else{
? ? ? ? alert("你為啥不打開慕課網(wǎng)?");
? ? ? ? }
? }
? else
? {
? ? ? alert("你沒有打開窗口!");
? }
?}
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="Wopen()" value="點擊我,彈出確認(rèn)對話框" />
</body>
</html>
點擊取消是無法輸入的,你是不是調(diào)用的地方函數(shù)寫的不對
2017-03-10
把prompt括號里面的 ? ?,"http://idcbgp.cn"去掉就可以了,只留下prompt(“請輸入你的網(wǎng)址:”)
然后在彈出框里面輸入愛慕網(wǎng)的網(wǎng)址,這個是沒有問題,能正常執(zhí)行
你在前面prompt加入了,相當(dāng)于默認(rèn)了這個網(wǎng)址,那么在下面就直接判斷條件就可以了,我是這么理解的。。
2017-03-10
寫的沒問題,可能是你修改后沒提交
2017-03-10
樓上正解
2017-03-10
?function Wopen(){
? ? var xinbox=confirm("是否新建窗口?");
? ? if(xinbox==true)//這個括號有問題是中文的,改回來就好了
? ? {
? ? ? ? var ttcaa=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
? ? ? ? if(ttcaa==null||ttcaa==" "){//這樣做判斷
? ? ? ??alert("你為啥不打開慕課網(wǎng)?");? ??
? ? ? ? }
? ? ? ? else{
? ? ? ? window.open(ttcaa,'_blank','width=600,height=500,left=100,top=100')
? ? ? ? }
? ? }
? ? else{
? ? ? ? alert("你沒有打開窗口!");
? ? }
}
2017-03-10
ttcaa是一個Bool型變量,應(yīng)該是if(ttcaa == true)