$(window).ready(function () {
$("html, body").css("overflow", "hidden");
var w, h;
if (window.innerWidth && window.innerHeight && window.outerWidth && window.outerHeight) {
w = $("body").outerWidth() + (window.outerWidth - window.innerWidth);
h = $("body").outerHeight() + (window.outerHeight - window.innerHeight);
} else {
var dW = $(document).outerWidth();
var dH = $(document).outerHeight();
window.resizeTo(dW, dH);
var lastW = dW - $(window).width();
var lastH = dH - $(window).height();
w = $("body").outerWidth() + lastW;
h = $("body").outerHeight() + lastH;
}
window.resizeTo(w, h);
});
팝업 크기를 자동으로 조절해주는 스크립트.
예전에 어디서 퍼와서 유용하게 썼었는데 출처를 잊어버렸다.
그래서 다시 검색해서 다른 곳의 출처를 달았다.
출처 :
http://blog.naver.com/afidev/20197202121
스크롤이 생길경우엔 스크롤길이를 더한다.
function getScrollBarWidth () { var inner = document.createElement('p'); inner.style.width = "100%"; inner.style.height = "200px"; var outer = document.createElement('div'); outer.style.position = "absolute"; outer.style.top = "0px"; outer.style.left = "0px"; outer.style.visibility = "hidden"; outer.style.width = "200px"; outer.style.height = "150px"; outer.style.overflow = "hidden"; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetWidth; outer.style.overflow = 'scroll'; var w2 = inner.offsetWidth; if (w1 == w2) w2 = outer.clientWidth; document.body.removeChild (outer); return (w1 - w2); };
'프로그래밍' 카테고리의 다른 글
robocopy (0) | 2015.09.22 |
---|---|
c#과 Java 비교 제네릭 (0) | 2015.08.22 |
네트워크 드라이브 연결하기 (0) | 2015.08.09 |
format-number 함수 (Xpath함수) (0) | 2015.02.13 |
파일 용량 표시 XSL, Function (0) | 2015.02.13 |