개발/Javascript

[Javascript] pop up ()

suniverse 2023. 1. 14. 21:37

<script type="text/javascript">
	let newPopup = window.open("test28_popup1.html", "popup", "width=500, height=400");
	if(newPopup == null){
		alert("팝업 차단됨. 팝업 차단을 해제해 주세요!");
	}
	
	function newWindow(){
		window.open("test28_popup2.html", "popup", "width=400, height=300, left=500, top=400");
	}
	function closeWindow(){
		let selectResult = confirm("현재 창을 닫고 종료하시겠습니까?");
		if(selectResult){ // true 라는 의미. !붙이면 false
			window.close();
		}
	}
	function newWindow2(){
		window.open("test29.html", "", "");
	}
</script>
</head>
<body>
	<h1>test28.html</h1>
	<input type="text" placeholder="주소 입력">
	<input type="button" value="주소검색" onclick="newWindow()">
	<input type="button" value="닫기" onclick="closeWindow()">
	<hr>
	<input type="button" value="test29.html 열기" onclick="newWindow2()">
</body>

 

💻

  • 팝업창 출력 

 

주소검색 창을 누르면? 

 

닫기를 누르면?