第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

我的代碼里的 關(guān)閉新打開窗口 怎么實現(xiàn)?

<!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 newWin = confirm("你要打開新的網(wǎng)頁窗口嗎?");
?? ??? ?if(newWin == true){
?? ??? ???? op();
?? ??? ?}else{
?? ??? ??? ?alert("好的再見!");
?? ??? ?};?? ?
?? ?}
?? ?
??? function op(){
????? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
?? ??? ??? ?var purl = "http://idcbgp.cn";
?? ??? ??? ?var input = prompt("請輸入網(wǎng)址打開新窗口",purl);
?? ??? ??? ?var x=0;
?? ??? ??? ?var y=0;
?? ??? ??? ?if(input != null){//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄
?? ??? ??? ??? ??? ?var win = open(purl,"_blank","top=y,left=x,width=400,height=500,menubar=no,toolbar=no");
?? ??? ??? ?};
??? }
?? ?
?? ?function closeWin(){
?? ??? ?win.close();
?? ?}
? </script>
?</head>
?<body>
?<form>
?? ?? <input type="button" value="請單擊我打開新的窗口!" onclick="openWindow()" />
??? <input type="button" value="關(guān)閉新打開的窗口" onclick="closeWin()" />
</form>
?</body>
</html>

正在回答

2 回答

語法是 <窗口對象>.close() ,因此,你要在function外先聲明窗口變量。以下是我的代碼,看關(guān)鍵的兩行即可。

<!DOCTYPE?html>
<html>

	<head>
		<title>?new?document?</title>
		<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
		<script?type="text/javascript">
			var?win;?//聲明新窗口變量。
			function?openWindow()?{
				var?isnot?=?confirm("確定要打開慕課網(wǎng)嗎?");?//?新窗口打開時彈出確認框,是否打開
				if?(isnot)?{
					//打開窗口時,相當(dāng)于為變量賦值。
					win?=?window.open('http://idcbgp.cn/',?'_black',?'width=400,height=500,toolbar=no,scrollbars=no');
					//?通過輸入對話框,確定打開的網(wǎng)址,默認為?http://idcbgp.cn/
					//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
				}?else?{
					alert("您放棄打開慕課網(wǎng)!");
				}
			}

			function?closeWindow()?{
				win.close();?//關(guān)閉新窗口
			}
		</script>
	</head>

	<body>
		<input?type="button"?value="新窗口打開網(wǎng)站"?onclick="openWindow()"?/>
		<input?type="button"?value="關(guān)閉新窗口網(wǎng)站"?onclick="closeWindow()"?/>
	</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

MichaelYan0 提問者

非常感謝!
2015-09-29 回復(fù) 有任何疑惑可以回復(fù)我~
function?closeWin(){
????????window.close();
????}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

我的代碼里的 關(guān)閉新打開窗口 怎么實現(xiàn)?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號