사용자함수 현재 창(페이지)의 중앙으로 팝업창 띄우기
페이지 정보

본문
듀얼모니터나 특정한 위치에 페이지가 있을때 그 위치에서 중앙으로 팝업창을 열고자 한다면 다음과 같이 함수를 사용하세요.
---------------- JS --------------------------
function popupCenter(href,w,h){
var xPos = (document.body.clientWidth / 2) - (w / 2);
xPos += window.screenLeft; //듀얼 모니터일때....
var yPos = (screen.availHeight / 2) - (h / 2);
window.open(href,"pop_window","width="+w+",height="+h+", left="+xPos+", top="+yPos+", toolbars=no, resizable=no, scrollbars=no");
}
var xPos = (document.body.clientWidth / 2) - (w / 2);
xPos += window.screenLeft; //듀얼 모니터일때....
var yPos = (screen.availHeight / 2) - (h / 2);
window.open(href,"pop_window","width="+w+",height="+h+", left="+xPos+", top="+yPos+", toolbars=no, resizable=no, scrollbars=no");
}
--------------- TAG --------------------------------
<a href="http://www.bamtol.net/" onclick="popupCenter(this.href,800,600);">밤톨넷사이트를 중앙에 800x600으로 띄우기</a>
관련링크
- 이전글moveTo(); resizeTo(); 현재창 리사이징으로 화면에 풀로 채우기 15.05.15
- 다음글자바스크립트 전용 이벤트 핸들러 모음 15.05.15
댓글목록
등록된 댓글이 없습니다.

