๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT/Java - Spring Boot

[Spring Boot] ํŽ˜์ด์ง€์— ํŒ์—… ์ฐฝ ๋„์šฐ๊ธฐ

by ITyranno 2023. 11. 1.
728x90
๋ฐ˜์‘ํ˜•

 

 

 

ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค.

 

 

์˜ค๋Š˜์€ Spring Boot์™€ HTML์„ ํ™œ์šฉํ•˜์—ฌ ํŒ์—… ์ฐฝ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์˜ค๋Š˜ ํ•˜๋ฃจ ์ด ์ฐฝ์„ ์—ด์ง€ ์•Š๊ธฐ์™€ ๋‹ซ๊ธฐ ๋ฒ„ํŠผ ๋˜ํ•œ ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

 

 

๊ตฌํ˜„ ํ™”๋ฉด

 

 

 

 

์ž‘์„ฑ ์ฝ”๋“œ

 

 

popupmembership.html

 

<!DOCTYPE html>

<script>
    //์ฟ ํ‚ค์„ค์ •    
    function setCookie(name, value, expiredays) {
        var todayDate = new Date();
        todayDate.setDate(todayDate.getDate() + expiredays);
        document.cookie = name + '=' + escape(value) + '; path=/; expires=' + todayDate.toGMTString() + ';'
    }

    // ์ฟ ํ‚ค ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
    function getCookie(name) {
        var obj = name + "=";
        var x = 0;
        while (x <= document.cookie.length) {
            var y = (x + obj.length);
            if (document.cookie.substring(x, y) == obj) {
                if ((endOfCookie = document.cookie.indexOf(";", y)) == -1)
                    endOfCookie = document.cookie.length;
                return unescape(document.cookie.substring(y, endOfCookie));
            }
            x = document.cookie.indexOf(" ", x) + 1;

            if (x == 0) break;
        }
        return "";
    }

    // ๋‹ซ๊ธฐ ๋ฒ„ํŠผ ํด๋ฆญ์‹œ
    function closeWin(key) {
        var todaycloseyn = document.getElementById("todaycloseyn");
        if (todaycloseyn.checked) {
            setCookie('divpop' + key, 'Y', 1);
            window.close();
        }
    }

</script>

<body>

    <div>
        <a href="#" target="_parent" onclick="move()">
            <img src="pop.jpg" alt="">
        </a>

        <div class="button_area">
            <input type="checkbox" id="todaycloseyn" value="Y"> ์˜ค๋Š˜ ํ•˜๋ฃจ ์ด ์ฐฝ์„ ์—ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
            <a href='#' onclick="closeWin(1);"><button>๋‹ซ๊ธฐ</button></a>
        </div>
    </div>
    

    <script>
        function move() {
            opener.move();
            self.close();
        }
    </script>

</body>

</html>

 

 

 

 

PopupController.java

 

@GetMapping("/popupmembership")
	public String pop() {
		return "membership/popupmembership";
	}

 

 

 

index.html

 

<script>

  // ์ฟ ํ‚ค ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
  function getCookie(name) {
    var obj = name + "=";
    var x = 0;
    while (x <= document.cookie.length) {
      var y = (x + obj.length);
      if (document.cookie.substring(x, y) == obj) {
        if ((endOfCookie = document.cookie.indexOf(";", y)) == -1)
          endOfCookie = document.cookie.length;
        return unescape(document.cookie.substring(y, endOfCookie));
      }
      x = document.cookie.indexOf(" ", x) + 1;

      if (x == 0) break;
    }
    return "";
  }

  function move() {
    location = '/subscribe';
  }
  function popUp() {
    const value = getCookie('divpop1');
    if (!value) {
      window.open("popupmembership", "", "width=570px, height=600px");
    }

  }
  window.onload = function () {
    popUp();
  };
  
  </script?

 

 

 

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ํŽ˜์ด์ง€์— ํŒ์—… ์ฐฝ์„ ๋„์šฐ๊ณ  ์˜ค๋Š˜ ํ•˜๋ฃจ ์ด ์ฐฝ์„ ์—ด์ง€ ์•Š๊ธฐ์™€ ๋‹ซ๊ธฐ ๋ฒ„ํŠผ์„ ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•

loading