Web/JavaScript

[JavaScript] 새 창 열기

박 현 황 2021. 3. 7. 23:37

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="javascript:windowOpen();">
    버튼으로 창 열기
    </button>
    <a href="javascript:windowOpen();">링크로 창 열기</a>

    <script>
        function windowOpen() {
            window.open("http://www.naver.com",'winname','width=300,height=200');
        }
    </script>
</body>
</html>

 

 

width = 300, height = 200 으로 설정해놓아서 조그맣게 뜨는 것을 확인할 수 있다.