Auto-center popup layer in a window


JavaScript

These are your parameters to determine where the window will be positioned. PLACE IN JSHEADER

var hX = 10;
var vY = -50;
var nn=(navigator.appName.indexOf("Netscape")!=-1);
var dD=document,dH=dD.html,dB=dD.body,px=dD.layers?'':'px';
function floatMail(iX,iY,id){
	var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];		
	this[id+'O']=L;if(dD.layers)L.style=L;L.nX=L.iX=iX;L.nY=L.iY=iY;
	L.P=function(x,y){this.style.left=x+px;this.style.top=y+px;};L.Fm=function(){var pX, pY;	
	pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;	
	pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;	
	if(this.iY<0)pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;	
	this.nX+=.1*(pX+this.iX-this.nX);this.nY+=.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);
	setTimeout(this.id+'O.Fm()',33);};
	return L;
}
floatMail(hX,vY,'FloatMail').Fm();


THE OBJECT YOU WANT TO FLOAT

<div id="FloatMail" style="border:2 outset #444444; position: absolute;background-color: #000000;width:100px;padding:2px; left:4px; top:4px">
<center>Save & Close<br>Close</center>
</div>

Posted by fbrefere001 on Wednesday May 3, 2006