View Single Post
Old Apr 29th, 2005, 12:42 PM   #1
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
javascript and dhtml

Well im working on this script for class that is suppose to have an image follow around the mouse as the mouse moves around the screen but if the user double clicks the image will stay put and disable the image from following the mouse until the user double clicks again then it will start following the mouse again. well i dont want anyone to give me code on how to do this i just would like some help on getting the image to stay put on the double click. here is the code i currently have that makes the image follow the mouse pointer.

<?xml version = "1.0"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 <!-- onmousemove.html		  -->
 <!-- Demonstrating the onmousemove event  -->
 
 <html xmlns = "http://www.w3.org/1999/xhtml">
    <head>
 	  <title>DHTML Event Model - onmousemove event</title>
 	  <script type = "text/javascript">
 		<!--
 		function updateMouseCoordinates()
 		 {
 			coordinates.innerText = event.srcElement.tagName +
 			   " (" + event.offsetX + ", " + event.offsetY + ")";
 		 }
 		 function follow()
 		 {
 			 myImage.style.top = event.y;
 			 myImage.style.left = event.x;
 		 }
 		 function stay()
 		 {
 			 myImage.style.top = event.y;
 			 myImage.style.left = event.x;
 
 		 }
 
 		 document.ondblclick = stay;
 		 document.onmousemove = follow;
 
 		 // -->
 	  </script>
    </head>
 
    <body style = "background-color: wheat" onmousemove = "updateMouseCoordinates()">
 
 
 	  <img id="myImage" src = "orange.gif" style = "position: absolute;
 		 top: 100; left: 100" alt="orange" />
 
    </body>
 </html>

again im just looking for ideas on how to do this we are suppose to use
CSS absolute positioning, onmousemove and event.x/event.y to have an image follow the mouse as the user moves the mouse over the Web page. Disable this feature if the user double clicks (ondblclick). thats the actuall assignment if i didnt explain it well.
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote