티스토리 뷰
728x90
반응형
let popWidth = width; // 파업사이즈 너비
let popHeight = height; // 팝업사이즈 높이
let winWidth = document.body.clientWidth; // 현재창의 너비
let winHeight = document.body.clientHeight; // 현재창의 높이
let winX = window.screenX || window.screenLeft || 0;// 현재창의 x좌표
let winY = window.screenY || window.screenTop || 0; // 현재창의 y좌표
let left = winX + (winWidth - popWidth) / 2;
let top = winY + (winHeight - popHeight) / 2;
window.open('${pageContext.servletContext.contextPath }/admin/' + url, title, option + ", left=" + left + ", top=" + top + ", width=" + popWidth + ', height=' + popHeight);
위 소스를 이용하면 팝업창에 브라우저 중앙에 위치한다
듀얼 모니터일경우에도 적용가능
728x90
반응형
'JavaScript' 카테고리의 다른 글
[JavaScript & window] 자식창에서 부모창의 값을 가져오는법 (0) | 2019.06.13 |
---|---|
[주소검색API] 주소검색 API 사용 (0) | 2019.06.13 |
[JavaScript & window] 자식창이 종료되었는지 확인 (0) | 2019.06.13 |
[JavaScript & window] 페이지가 새로고침될때 작업하는방법 (1) | 2019.06.13 |
[JavaScript & window] 부모팝업창이 새로고침 or 종료되면 자식창을 다 제거하는방법 (0) | 2019.06.13 |
댓글