DHTML - Cursorfolgende Augen
Position in der html-Datei:
body
-Bereich, am Ende des Dokuments vor
</body>
<script type="text/javascript"> <!-- /* Watching Eyes Script By Virtual_Max http://www.geocities.com/siliconvalley/lakes/8620 Modified by Dynamicdrive.com (IE specific bug fixed) Permission granted to Dynamicdrive.com to include the script in it's archive For 100's more DHTML scripts, visit Dynamicdrive.com Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this notice appears in all copies. VIRTUAL MAX MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. VIRTUAL MAX SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ var brOK=false; var mie=false; var ex=0; var ey=0; var ae; var le; var re; var x0; var y0; var tid; var realx; var realy; var loaded=false; if(parseInt(navigator.appVersion.charAt(0))>=4) { brOK=true; } if(navigator.appName.indexOf("Microsoft")!=-1) { mie=true; } function myhandler(e) { ex=e.pageX; ey=e.pageY; moveeye() return routeEvent(e); } function moveeye() { dy=ey-y0-20; dx1=ex-x0-20; dx2=ex-x0-60; r=Math.sqrt(dx1*dx1+dy*dy); if(r<20) r=20 dx1=dx1*10/r+x0+10; dy1=dy*10/r+y0+10; r=Math.sqrt(dx2*dx2+dy*dy); if(r<20) r=20 dx2=dx2*10/r+x0+50; ae.left=x0; ae.top=y0; le.left=dx1; le.top=dy1; re.left=dx2; re.top=dy1; } function setHandlers() { if(!mie) { y0=document.eyeballs.top; x0=document.eyeballs.left; ae=document.eyeballs; le=document.lefteye; re=document.righteye; window.captureEvents(Event.MOUSEMOVE); window.onMouseMove=myhandler; } else { y0=document.all.eyeballs.style.pixelTop; x0=document.all.eyeballs.style.pixelLeft; ae=document.all.eyeballs.style; le=document.all.lefteye.style; re=document.all.righteye.style; } realx=x0+0.1; realy=y0+0.1; moveall(); loaded=true; } function moveall() { rx=realx+40 ry=realy+40; rx+=(ex-rx)*0.1; ry+=(ey-ry)*0.1; realx=rx-40; realy=ry-40; x0=Math.round(realx); y0=Math.round(realy); moveeye(); tid=setTimeout('moveall()',100); } function placeeyes(x,y) { if(brOK) { ex=x+40; ey=y+40; s ='<div id="dummy" style="position:absolute; top:'+y+'; left:'+x+'; width:10; height:10;"> <\/div>'; s+='<div id="eyeballs" style="position:absolute; top:'+y+'; left:'+x+'; width:80; height:40;"><img src="js/dhtml_cursor_verfolgendeaugen_eyeballs.gif" border="0" alt="" /><\/div>'; s+='<div id="lefteye" style="position:absolute; top:'+(y+10)+'; left:'+(x+10)+'; width:20; height:20;"><img src="js/dhtml_cursor_verfolgendeaugen_eye.gif" border="0" alt="" /><\/div>'; s+='<div id="righteye" style="position:absolute; top:'+(y+10)+'; left:'+(x+50)+'; width:20; height:20;"><img src="js/dhtml_cursor_verfolgendeaugen_eye.gif" border="0" alt="" /><\/div>'; document.writeln(s); } } //--> </script> <script type="text/javascript" for="document" event="onmousemove()"> <!-- if((mie==true)&&(brOK)&&loaded) { ex=document.body.scrollLeft+event.x; ey=document.body.scrollTop+event.y; moveeye(); } //--> </script> <script type="text/javascript"> <!-- if (document.all||document.layers) placeeyes(200,100); //--> </script>
Position in der html-Datei:
body
-Tag
onload="initButton();if(brOK) setHandlers()" onunload="if(brOK) {if(tid) clearTimeout(tid);}"
Quelle:
http://www.dynamicdrive.com/dynamicindex4/watcheye.htm
.
© 2001