[위치관련]팝업창을 브라우저 해상도 구분없이 항상 중앙에 띄우기
// 팝업창 중앙으로 위치
function center(){
var x,y;
if (self.innerHeight) { // IE 외 모든 브라우저
x = (screen.Width - self.innerWidth) / 2;
y = (screen.Height - self.innerHeight) / 2;
}else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드
x = (screen.Width - document.documentElement.clientWidth) / 2;
y = (screen.Height - document.documentElement.clientHeight) / 2;
}else if (document.body) { // 다른 IE 브라우저( IE < 6)
x = (screen.Width - document.body.clientWidth) / 2;
y = (screen.Height - document.body.clientHeight) / 2;
}
window.moveTo(x,y);
}
// 사용시 : 팝업 스크립트나 팝업파일의 가장 하단에
<script type="text/javascript" language="JavaScript">
<!--
center();
//-->
</script><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
function center(){
var x,y;
if (self.innerHeight) { // IE 외 모든 브라우저
x = (screen.Width - self.innerWidth) / 2;
y = (screen.Height - self.innerHeight) / 2;
}else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드
x = (screen.Width - document.documentElement.clientWidth) / 2;
y = (screen.Height - document.documentElement.clientHeight) / 2;
}else if (document.body) { // 다른 IE 브라우저( IE < 6)
x = (screen.Width - document.body.clientWidth) / 2;
y = (screen.Height - document.body.clientHeight) / 2;
}
window.moveTo(x,y);
}
// 사용시 : 팝업 스크립트나 팝업파일의 가장 하단에
<script type="text/javascript" language="JavaScript">
<!--
center();
//-->
</script><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
댓글 1개
Photofly
19년 전
아주 유용한 팁이군요... 감사합니다..^^
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 626 | 기타 | 19년 전 | 4226 | ||
| 625 | JavaScript |
|
19년 전 | 3424 | |
| 624 | JavaScript |
|
19년 전 | 3350 | |
| 623 | 기타 |
|
19년 전 | 2828 | |
| 622 | 기타 |
pearly
|
19년 전 | 4722 | |
| 621 | JavaScript | 19년 전 | 3487 | ||
| 620 | Flash |
|
19년 전 | 7764 | |
| 619 | 기타 | 19년 전 | 3641 | ||
| 618 | JavaScript |
|
19년 전 | 3475 | |
| 617 | 기타 |
|
19년 전 | 4152 | |
| 616 | 기타 |
|
19년 전 | 3107 | |
| 615 | JavaScript | 19년 전 | 3519 | ||
| 614 | 기타 | 19년 전 | 4173 | ||
| 613 | 기타 |
|
19년 전 | 6885 | |
| 612 | JavaScript | 19년 전 | 4232 | ||
| 611 | 기타 |
|
19년 전 | 6297 | |
| 610 | Flash | 19년 전 | 5037 | ||
| 609 | Flash | 19년 전 | 5935 | ||
| 608 | Flash |
홀로남은자
|
19년 전 | 5518 | |
| 607 | 기타 | 19년 전 | 4667 | ||
| 606 | PHP |
|
19년 전 | 3987 | |
| 605 | 기타 |
|
19년 전 | 3760 | |
| 604 | 기타 |
|
19년 전 | 4345 | |
| 603 | JavaScript |
|
19년 전 | 3871 | |
| 602 | 기타 |
|
19년 전 | 3846 | |
| 601 | 기타 |
|
19년 전 | 3445 | |
| 600 | JavaScript |
|
19년 전 | 4743 | |
| 599 | 기타 |
|
19년 전 | 3983 | |
| 598 | 기타 |
|
19년 전 | 4413 | |
| 597 | 기타 |
|
19년 전 | 3342 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기