IT_Programming/JavaScript

화면 절대 좌표 찾는 스크립트

JJun ™ 2008. 1. 25. 12:16
(window 화면 절대 좌표 팝업 할때 엽에 뛰우기)

 function PopupOpen(evt)
 {
  var maxW,maxH,fromX,fromY,toX,toY,adjX,adjY,zBox,zStep=0,zLink,zNew;
  scrollH=(window.pageYOffset!=null)?window.pageYOffset:document.body.scrollTop;

  maxW= document.body.clientWidth;
  maxH= document.body.clientHeight;
  
  toX= 50?50:(window.screen.width/2-maxW/2);
  toY=(50?50:(window.screen.height/2-maxH/2-150))+scrollH;
  
  fromX=evt.pageX?evt.pageX:evt.clientX;
  fromY=(evt.pageY?evt.pageY:evt.clientY)+(document.all?scrollH:0);
  adjX=toX+evt.screenX - 290;
  adjY=toY+evt.screenY-fromY + 40;

  var sUrl = "/servlet/service?cmd=frame.include.PlantSelectObjCommand_getPlantSelect";
  var winModify = showModelessDialog(sUrl, window,"dialogHeight: 160px; dialogWidth: 270px; dialogTop: "+ adjY+"px; dialogLeft: "+adjX+"px; edge: Sunken; center: No; help: No; resizable: No; status: No;scroll:no");
  
  winModify.focus();
  winModify.opener = self;
 }

출처 : http://www.okjsp.pe.kr/bbs?act=VIEW&seq=47484&bbs=bbs4&keyfield=content&keyword=&pg=2