팝업창 중앙에 띄우기
<script>
$(function() {
$("a.open-window").on("click", function(e) {
e.preventDefault();
const link = $(this).attr("href");
const popupWidth = 500;
const popupHeight = 500;
const screenLeft = window.screenLeft ?? window.screenX;
const screenTop = window.screenTop ?? window.screenY;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
const left = screenLeft + (screenWidth - popupWidth) / 2;
const top = screenTop + (screenHeight - popupHeight) / 2;
window.open(link, "register", `width=${ popupWidth }, height=${ popupHeight }, top=${ top }, left=${ left }, scrollbars=no`);
});
});
</script>
<a href="https://naver.com" class="open-window">naver</a>