Betty_S Posted January 21, 2007 Share Posted January 21, 2007 Hi folks!I want to move a div according to client's mouse X,Y so I wrote that: <script>function mouseXY(){var X = event.clientX;var Y = event.clientY;document.getElementById("movingDiv").style.top=X;document.getElementById("movingDiv").style.left=Y;}window.onload=mouseXY;</script></head><body onmousemove="java script:mouseXY();"> <div id="movingDiv" style="top=0;left=0;position:absolute;border-color:#000000;border:groove;width:250px;height:96px;background-color:#CCCCCC" onClick="java script:this.style.display='none';"></body> Well, the div moves but its not attached to the mouse X and Y.What can I do? Thanks. Link to comment Share on other sites More sharing options...
MrAdam Posted January 21, 2007 Share Posted January 21, 2007 i once had this problem .. try this: function mouseXY(event) { mouseXY(event); Link to comment Share on other sites More sharing options...
Betty_S Posted January 21, 2007 Author Share Posted January 21, 2007 i once had this problem .. try this:function mouseXY(event) { mouseXY(event); ??? Link to comment Share on other sites More sharing options...
jesh Posted January 22, 2007 Share Posted January 22, 2007 ???I believe MrAdam means:<script>function mouseXY(e){// so that it'll work in DOM compliant browsers as well as IEe = (e) ? e : window.event; var X = e.clientX;var Y = e.clientY;document.getElementById("movingDiv").style.top=X;document.getElementById("movingDiv").style.left=Y;}window.onload=mouseXY;</script></head><body onmousemove="mouseXY(event);"> Link to comment Share on other sites More sharing options...
Betty_S Posted January 24, 2007 Author Share Posted January 24, 2007 find it: developer.beormaxdesign Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now