Thread: move text
View Single Post
  #4 (permalink)  
Old 11-14-09, 11:23 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
HTML Code:
<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>
Tested in FF3, IE7
Reply With Quote