<body id="bd"> <span id="test" onclick="bork(this)" style="position:absolute">Test</span> <script type="text/javascript"> r=document.getElementById('bd').getClientRects().item(0); function bork(e) { sw=screen.width; sh=screen.height; cr=r.right; cl=r.left; cw=cr-cl; ct=r.top; cb=r.bottom; ch=cb-ct; t.style.left=(cw/2-(sw-cw)/2).toString()+"px"; t.style.top=(ch/2-(sh-ch)/2).toString()+"px"; } </script>