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
๋ฐ์ํ