Thread: move text
View Single Post
  #5 (permalink)  
Old 11-15-09, 09:46 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Lol, either I'm having tremendously bad luck today, or something.... I couldn't get this to work. Is it possible that "t.style.left....." etc should be "e.style.left...."?

If I change "t" to "e" and then click on the word 'Test', it just disappears.


Quote:
Originally Posted by wirehopper View Post
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
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote