HTML Window resizeTo() 메서드는 지정된 값만큼 현재 크기를 기준으로 창 크기를 조정합니다.
구문
다음은 구문입니다 -
window.resizeTo(w,h)
여기 w 그리고 h 창 너비와 높이를 각각 픽셀 단위로 크기 조정하는 값을 정의합니다.
HTML Window resizeTo() 메서드의 예를 살펴보겠습니다. -
예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%) no-repeat;
text-align: center;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 20%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
<body>
<h1>HTML Window resizeTo() Method Demo</h1>
<button onclick="create()" class="btn">Create a new window</button>
<button onclick='resize()' class="btn">Resize the window</button>
<script>
var newWindow;
function create(){
newWindow =window.open('','','width=80,height=80');
}
function resize(){
newWindow.resizeTo(240, 240);
newWindow.focus();
}
</script>
</body>
</html> 출력

"새 창 만들기를 클릭합니다. ” 버튼을 눌러 새 창 생성:

이제 새로 생성된 창의 크기를 조정하려면 "창 크기 조정" 버튼을 클릭하십시오 -
