상세 컨텐츠

본문 제목

브라우져 버젼별 resizeTo height 변경하는 함수

프로그래밍/스크립트

by 라제폰 2011. 4. 22. 15:44

본문


function resizePopup(w) { 
 var h=0;
 var Browser = new Object(); 
 Browser.isIE = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
 Browser.isIE_SV1 = (navigator.userAgent.toLowerCase().indexOf("sv1")!=-1);
 Browser.isIE_SV2 = (navigator.userAgent.toLowerCase().indexOf("sv2")!=-1);
 Browser.isIE_7 = (navigator.userAgent.toLowerCase().indexOf("msie 7")!=-1);
 Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
 Browser.isSafari =(navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
 Browser.isOpera =(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
 Browser.isNetscape =(navigator.userAgent.toLowerCase().indexOf("netscape")!=-1);

 var popWrap = document.getElementsByTagName("body")[0];
 if(popWrap.className.indexOf("popType") > -1){
  var currentPopHeight = popWrap.offsetHeight;
  var popHeight = currentPopHeight + 35;   
  if(popHeight < 700){
   //var re_top = Math.floor((screen.height/2)-(popHeight/2)); //중앙
   //var re_left = Math.floor((screen.width/2)-(w/2));//중앙   
   if (Browser.isIE_SV1) { h = 14; }
   else if(Browser.isIE_7) { h = 45; }
   else if(Browser.isEtc) { h = 22; }
   else if(Browser.isFirefox) { h = 15; }
   else if(Browser.isNetscape) { h = -2; }
   else if(Browser.isOpera) { h = 28; }          
   window.resizeTo(w+10,popHeight+h); //리사이즈
   popWrap.setAttribute("scroll","no");
  }else{
   window.resizeTo(w+46,700);
   document.body.scroll = "yes";
  }
 } 
}

관련글 더보기