JS pop up layer simple absolute positioning centered sample code

  • 2020-03-30 01:48:57
  • OfStack

 
function doThis() 
{ 
var a = document.getElementById("addYear"); 
a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+"px"; 
a.style.top=(document.body.scrollTop+document.body.clientHeight/2-a.clientHeight/2)+"px"; 
} 

Related articles: