개발/html

#2. 버튼 클릭 시 팝업윈도우 및 html 실행

크리소탈 2024. 6. 22. 15:59
728x90
반응형
SMALL

 

1. 팝업뜨게 하는 법 : openpopup

<a class="button minsobabo" onclick="openPopup('xxxx.html')"> 바로가기</a>

 

  <script>
   /* 생략 function openPopup(url) {
        window.open(url, "PopupWindow", "width=600,height=400,scrollbars=yes");
    } */
    
    </script>
    <style></style>
</head>

<body>

    <div class="button-container">
        <a class="button minsobabo" onclick="window.open('웹주소입력')">버튼이름</a>
    </div>

 

2. URL 뜨게하는 법: window.open

<a class="button minsobabo" onclick="window.open(URL주소를 입력하세요)"> 바로가기</a>

 

  <script>
    function openPopup(url) {
        window.open(url, "PopupWindow", "width=600,height=400,scrollbars=yes");
    }
    
    </script>
    <style></style>
</head>

<body>

    <div class="button-container">
        <a class="button minsobabo" onclick="openPopup('특정파일.html')">버튼이름</a>
    </div>

 

 

  • 전체 코드 예시
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>웰컴 투 ㅇㅇㅇㅇ</title>

    <script>
    function openPopup(url) {
        window.open(url, "PopupWindow", "width=600,height=400,scrollbars=yes");
    }
    
    </script>
    <style></style>
</head>

<body>

    <div class="button-container">
        <a class="button minsobabo" onclick="window.open('웹주소입력')">버튼이름</a>
        <a class="button minsobabo" onclick="openPopup('특정파일.html')">버튼이름</a>
    </div>


</body>

</html>

 

 

 

728x90
반응형
LIST