Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracers from your mouse on the webpage??????

Status
Not open for further replies.

sknyppy

Programmer
May 14, 1999
137
US
How is this done?
 
I heavn't seen this done yet myself, but if you give me the URL of a site that you saw what you are wanting on I'm sure I can figure out how they did it, then tinker around with it until I can make it work for your site.<br>
<br>
<br>
-Robherc<br>
<br>
robherc@netzero.net
 
Here's all I could find on their site that seems to relate to the mouse trails; please let me know if it works:<br>
<br>
<br>
&lt;html&gt;<br>
&lt;head&gt;<br>
&lt;style&gt;&lt;!--<br>
#trailsprite1 { position: absolute; z-index: 100; top: 1px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
#trailsprite2 { position: absolute; z-index: 10; top: 0px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
#trailsprite3 { position: absolute; z-index: 10; top: 0px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
#trailsprite4 { position: absolute; z-index: 10; top: 0px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
#trailsprite5 { position: absolute; z-index: 10; top: 0px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
#trailsprite6 { position: absolute; z-index: 10; top: 0px; left: 0px; width: 10px; height: 10px; visibility: visible }<br>
&lt;/style&gt;<br>
&lt;/head&gt;<br>
&lt;body&gt;<br>
&lt;DIV id="trailSprite1"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite1img"&gt;&lt;/DIV&gt;&lt;DIV id="trailSprite2"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite2img"&gt;&lt;/DIV&gt;&lt;DIV id="trailSprite3"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite3img"&gt;&lt;/DIV&gt;&lt;DIV id="trailSprite4"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite4img"&gt;&lt;/DIV&gt;&lt;DIV id="trailSprite5"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite5img"&gt;&lt;/DIV&gt;&lt;DIV id="trailSprite6"&gt;&lt;IMG src="trailgif5.gif" height="10" width="10" border="0" name="trailSprite6img"&gt;&lt;/DIV&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;<br>
<br>
I hope you are able to use this (Oh, and the "&lt;div&gt;" tags and the data between them was all RIGHT under the "&lt;body&gt;" tag, it might not work if they are located further down in the code; I'm just not sure)<br>
<br>
<br>
-Robherc<br>

 
Oops, don't bother; I tried it out on a page on my own system & it didn't work at all. I'll try downloading the entire source for the Philops page so I can search it more throughly for whatever JavaScript is involved in this; I have a feeling that it is probably a pretty complicated one, but only time will tell.<br>
Sorry I couldn't deliver a working solution on the first try; but sometimes thatt's how it goes with JS.<br>
<br>
-Robherc
 
Well, I'm not sure if this will help or not, but it seems as though it may have some similar functions to tracing the mouse movement. I found a script at The JavaScript Source at in which a pair of eyes follow your mouse around the screen. The code (and installation) is as follows:<br>
<br>
&lt;!-- FOUR STEPS TO INSTALL EYES!:<br>
<br>
1. Paste the coding into the HEAD of your HTML document<br>
2. Add the onLoad event handler to the BODY tag<br>
3. Put the last coding into the BODY of your HTML document <br>
4. Save the two images to your web site directory --&gt;<br>
<br>
&lt;!-- STEP ONE: Copy this code into the HEAD of your HTML document --&gt;<br>
<br>
&lt;HEAD&gt;<br>
<br>
&lt;SCRIPT LANGUAGE=JavaScript1.2&gt;<br>
<br>
&lt;!-- Original: --&gt;<br>
<br>
&lt;!-- This script and many more are available free online at --&gt;<br>
&lt;!-- The JavaScript Source!! --&gt;<br>
<br>
&lt;!-- Begin<br>
var x, y;<br>
var LastEvent = new Event;<br>
var EYESWIDTH = 50;<br>
var EYESHEIGHT = 14; <br>
var PUPIL_OFFSETX = 5;<br>
var PUPIL_OFFSETY = 5;<br>
var R = 5;<br>
function myMouseMove(e) {<br>
LastEvent = e;<br>
EYE1_OFFSETX = document.layers.EYES.left+EYESWIDTH/4;<br>
EYE1_OFFSETY = document.layers.EYES.top+EYESHEIGHT/2;<br>
EYE2_OFFSETX = document.layers.EYES.left+EYESWIDTH/4*3;<br>
EYE2_OFFSETY = document.layers.EYES.top+EYESHEIGHT/2;<br>
calcNewOffset(e.pageX, e.pageY, EYE1_OFFSETX, EYE1_OFFSETY, R);<br>
document.layers.PUPIL1.moveTo(x, y);<br>
calcNewOffset(e.pageX, e.pageY, EYE2_OFFSETX, EYE2_OFFSETY, R);<br>
document.layers.PUPIL2.moveTo(x, y);<br>
var retval = routeEvent(e);<br>
if (retval == false) return false;<br>
else return true;<br>
}<br>
function calcNewOffset(px, py, EYE_OFFSETX, EYE_OFFSETY, R){<br>
var x2, y2, m;<br>
y2 = (py - EYE_OFFSETY);<br>
x2 = (px - EYE_OFFSETX);<br>
if (x2==0)<br>
x2=0.0000001; //prevent infinity<br>
r = Math.sqrt(x2*x2+y2*y2);<br>
if (r&lt;=R) {<br>
x = Math.round(px - PUPIL_OFFSETX);<br>
y = Math.round(py - PUPIL_OFFSETY);<br>
return;<br>
}<br>
m = Math.abs(y2/x2);<br>
x = Math.sqrt(R*R/(1+m*m));<br>
y = m*x;<br>
if (x2&lt;0) x = -x;<br>
if (y2&lt;0) y = -y;<br>
x = x + EYE_OFFSETX - PUPIL_OFFSETX;<br>
y = y + EYE_OFFSETY - PUPIL_OFFSETY;<br>
x = Math.round(x);<br>
y = Math.round(y);<br>
}<br>
function myLoad() {<br>
EYE1_OFFSETX = document.layers.EYES.left+EYESWIDTH/4;<br>
EYE1_OFFSETY = document.layers.EYES.top+EYESHEIGHT/2;<br>
EYE2_OFFSETX = document.layers.EYES.left+EYESWIDTH/4*3;<br>
EYE2_OFFSETY = document.layers.EYES.top+EYESHEIGHT/2;<br>
document.layers.PUPIL1.moveTo(EYE1_OFFSETX, EYE1_OFFSETY);<br>
document.layers.PUPIL2.moveTo(EYE2_OFFSETX, EYE2_OFFSETY);<br>
window.onMouseMove=myMouseMove;<br>
window.captureEvents(Event.MOUSEMOVE);<br>
// setTimeout("moveEyesTimer()", 10);<br>
}<br>
function moveEyesTimer() {<br>
var Dy, Dx, dist;<br>
dist = Math.sqrt(Math.pow((document.layers.EYES.left+EYESWIDTH/2-LastEvent.pageX),2) +<br>
Math.pow((document.layers.EYES.top+EYESHEIGHT/2-LastEvent.pageY),2));<br>
Dx = Math.round(3*(document.layers.EYES.left+EYESWIDTH/2-LastEvent.pageX)/dist);<br>
Dy = Math.round(3*(document.layers.EYES.top+EYESHEIGHT/2-LastEvent.pageY)/dist);<br>
if (Math.abs(dist)&lt;=5){<br>
Dx = 0;<br>
DY = 0;<br>
}<br>
document.layers.EYES.left -= Dx;<br>
document.layers.EYES.top -= Dy;<br>
myMouseMove(LastEvent);<br>
setTimeout("moveEyesTimer()", 10);<br>
}<br>
// End --&gt;<br>
&lt;/SCRIPT&gt;<br>
&lt;/HEAD&gt;<br>
<br>
&lt;!-- STEP TWO: Add the onLoad event handler to the BODY tag --&gt;<br>
<br>
&lt;BODY onLoad="myLoad()"&gt;<br>
<br>
&lt;!-- STEP THREE: Add this coding into the BODY of your HTML document --&gt;<br>
<br>
&lt;CENTER&gt;<br>
&lt;LAYER ID=EYES&gt;<br>
&lt;IMG SRC=&lt;/LAYER&gt;<br>
&lt;LAYER ID=PUPIL1&gt;<br>
&lt;IMG SRC=&lt;/LAYER&gt;<br>
&lt;LAYER ID=PUPIL2&gt;<br>
&lt;IMG SRC=&lt;/LAYER&gt;<br>
<br>
&lt;!-- STEP FOUR: Save the following images to your web site directory --&gt;<br>
<br>
<br>
&lt;!-- Script Size: 3.18 KB --&gt;<br>
<br>
I hope this helps somewhat (even if it is a little unrelated)<br>
-Grebo
 
<br>
Grebo-<br>
Accchhh!!!! You found a BIG ONE that time Grebo! I'll try to sort through this script to find out exactly which parts are involved in tracing the mouse motion; maybe comparing it to the JavaScript on the philips page will help.<br>
<br>
<br>
Sknyppy-<br>
I'll try to sort through these JavaScripts to find the important parts for you as soon as possible, but I'm afraid this one might tae a little while.<br>
<br>
<br>
<br>
-Robherc
 
Sorry I haven't been in for soooo long; I'm really busy with a COUPLE of jobs right now, so my JS adventures have temporarily come to an end; I'm REALLY sorry I wasn't able to be of any more help.<br>
<br>
<br>
-Robherc<br>
robherc@netzero.net
 
I know how to trace the mouse, it depends on if you use IE or Netscape, you'll have to use different JS operations for each. I wrote a function to trace where the mouse is then create a image at that point when the mouse is clicked (approprately named dartToss). Here is the code of the function, if you want to see it in action goto and click on the large imagemap a couple of times (only works in Netscape so far). Pay special attention to the moveToAbsolute.<br>
<br>
var cdarts = 7;<br>
var wdarts = 12;<br>
function dartToss (answerCheck,evt,wrongBox,sHint,sAnswer) { //VERY layer dependent, if change layers, change numbers<br>
if (answerCheck == 1) {<br>
parent.lFrame.document.layers[cdarts].moveToAbsolute(evt.layerX - 9, evt.layerY - 5);<br>
parent.lFrame.document.layers[cdarts].visibility = "visible";<br>
cdarts ++;<br>
for (cLayers = 0; cLayers &lt; 7; cLayers++) //change accordingly at cLayers &lt; #<br>
parent.lFrame.document.layers[cLayers].visibility = "hidden";<br>
parent.lFrame.document.cssBox1c.visibility = "visible";<br>
parent.lFrame.document.bigCircle.visibility = "visible";<br>
parent.lFrame.document.rBox.visibility = "visible";<br>
if (cdarts == 12)<br>
cdarts = 7;<br>
<br>
}<br>
if (answerCheck != 1) {<br>
parent.lFrame.document.layers[wdarts].moveTo(evt.layerX - 9, evt.layerY - 5);<br>
parent.lFrame.document.layers[wdarts].visibility = "visible";<br>
wdarts ++;<br>
while (wrongBox &gt; 0) {<br>
for (cLayers = 0; cLayers &lt; 7; cLayers++) //change accordingly at cLayers &lt; #<br>
parent.lFrame.document.layers[cLayers].visibility = "hidden";<br>
parent.lFrame.document.layers[wrongBox + 1].visibility = "visible";<br>
wrongBox = 0;<br>
}<br>
if (wdarts == 17)<br>
wdarts = 12;<br>
}<br>
if (sHint == 1) {<br>
for (cLayers = 0; cLayers &lt; 6; cLayers++) //change accordingly at cLayers &lt; #<br>
parent.lFrame.document.layers[cLayers].visibility = "hidden";<br>
parent.lFrame.document.hintBox1.visibility = "visible";<br>
}<br>
if (sAnswer == 1) {<br>
parent.lFrame.document.bigCircle.visibility = "visible";<br>
}<br>
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top