FrickenTrevor
08-28-2012, 08:34 PM
Hey thanks for taking a look at this :)
There's this script that works on every browser (even IE 9, out of all the things) but not on Chrome.
Can someone help me to re-write this so it works for chrome? Im not the best at JavaScript :p
Here's the site (the code is also bellow):
http://rainbow.arch.scriptmania.com/scripts/snoopy_cursor_trail.html
<SCRIPT type="text/javascript">
var Ver4=parseInt(navigator.appVersion.charAt(0))>=4
var IE=navigator.appName.indexOf("Microsoft")!=-1
var al, imagesrc, ex=-32, ey=-32, x0=-32, y0=-32
function MoveSnoop()
{
if (Math.abs(ex-x0)>=10) { x0+=Math.floor((ex-x0)*0.1) }
else if (ex!=x0) { x0+=Math.abs(ex-x0)/(ex-x0) }
if (Math.abs(ey-y0)>=10) { y0+=Math.floor((ey-y0)*0.1) }
else if (ey!=y0) { y0+=Math.abs(ey-y0)/(ey-y0) }
imagesrc=""
if ( (ex<x0) && ( (x0-ex) > Math.abs(y0-ey)/2 ) )
{ imagesrc="snoopl.gif"
if ( (x0-ex) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="snoopl.gif"
if (ey>y0) imagesrc="snoopl.gif"
}
}
if ( (ex>x0) && ( (ex-x0) > Math.abs(y0-ey)/2) )
{ imagesrc="snoopr.gif"
if ( (ex-x0) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="snoopr.gif"
if (ey>y0) imagesrc="snoopr.gif"
}
}
if (imagesrc=="")
{ if (ey<y0) imagesrc="snoopr.gif"
if (ey>y0) imagesrc="snoopr.gif"
if ((ex==x0)&&(ey==y0)) imagesrc="snoop.gif"
}
if (Ver4)
{ if (!IE)
{ document.FlyLayer.document.images.fly.src=imagesrc }
else document.all.FlyLayer.document.images.fly.src=imagesrc
}
al.left=x0-47
al.top=y0
setTimeout("MoveSnoop();",100)
}
function MainMouseEvent(e)
{
if (Ver4)
{ if (!IE)
{ ex=e.pageX
ey=e.pageY }
else
{ ex=event.clientX + document.body.scrollLeft
ey=event.clientY + document.body.scrollTop }
}
}
function ScriptSetup()
{
isIm = (document.images) ? 1 : 0
if (isIm)
{ arImLoad = new Array
('snoop','snoopl','snoopr')
arImList = new Array ()
for (counter in arImLoad)
{ arImList[counter] = new Image()
arImList[counter].src = arImLoad[counter] + '.gif'
}
}
if (Ver4)
{ if (!IE)
{ al=document.FlyLayer
document.captureEvents(Event.MOUSEMOVE)
}
else
{ al=document.all.FlyLayer.style }
document.onmousemove = MainMouseEvent
MoveSnoop()
}
}
function ShowSnoop()
{
if(Ver4)
{ s ='<DIV STYLE="visibility:hidden"></DIV>'
s+='<DIV ID="FlyLayer" STYLE="position:absolute; '
s+='top:-32; left:-32; width:32; height:32">'
s+=''
s+='<IMG NAME="fly" SRC="snoop.gif" border=0>'
s+='</A></DIV>'
document.writeln(s)
}
}
window.onload = ScriptSetup
ShowSnoop()
</SCRIPT>
There's this script that works on every browser (even IE 9, out of all the things) but not on Chrome.
Can someone help me to re-write this so it works for chrome? Im not the best at JavaScript :p
Here's the site (the code is also bellow):
http://rainbow.arch.scriptmania.com/scripts/snoopy_cursor_trail.html
<SCRIPT type="text/javascript">
var Ver4=parseInt(navigator.appVersion.charAt(0))>=4
var IE=navigator.appName.indexOf("Microsoft")!=-1
var al, imagesrc, ex=-32, ey=-32, x0=-32, y0=-32
function MoveSnoop()
{
if (Math.abs(ex-x0)>=10) { x0+=Math.floor((ex-x0)*0.1) }
else if (ex!=x0) { x0+=Math.abs(ex-x0)/(ex-x0) }
if (Math.abs(ey-y0)>=10) { y0+=Math.floor((ey-y0)*0.1) }
else if (ey!=y0) { y0+=Math.abs(ey-y0)/(ey-y0) }
imagesrc=""
if ( (ex<x0) && ( (x0-ex) > Math.abs(y0-ey)/2 ) )
{ imagesrc="snoopl.gif"
if ( (x0-ex) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="snoopl.gif"
if (ey>y0) imagesrc="snoopl.gif"
}
}
if ( (ex>x0) && ( (ex-x0) > Math.abs(y0-ey)/2) )
{ imagesrc="snoopr.gif"
if ( (ex-x0) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="snoopr.gif"
if (ey>y0) imagesrc="snoopr.gif"
}
}
if (imagesrc=="")
{ if (ey<y0) imagesrc="snoopr.gif"
if (ey>y0) imagesrc="snoopr.gif"
if ((ex==x0)&&(ey==y0)) imagesrc="snoop.gif"
}
if (Ver4)
{ if (!IE)
{ document.FlyLayer.document.images.fly.src=imagesrc }
else document.all.FlyLayer.document.images.fly.src=imagesrc
}
al.left=x0-47
al.top=y0
setTimeout("MoveSnoop();",100)
}
function MainMouseEvent(e)
{
if (Ver4)
{ if (!IE)
{ ex=e.pageX
ey=e.pageY }
else
{ ex=event.clientX + document.body.scrollLeft
ey=event.clientY + document.body.scrollTop }
}
}
function ScriptSetup()
{
isIm = (document.images) ? 1 : 0
if (isIm)
{ arImLoad = new Array
('snoop','snoopl','snoopr')
arImList = new Array ()
for (counter in arImLoad)
{ arImList[counter] = new Image()
arImList[counter].src = arImLoad[counter] + '.gif'
}
}
if (Ver4)
{ if (!IE)
{ al=document.FlyLayer
document.captureEvents(Event.MOUSEMOVE)
}
else
{ al=document.all.FlyLayer.style }
document.onmousemove = MainMouseEvent
MoveSnoop()
}
}
function ShowSnoop()
{
if(Ver4)
{ s ='<DIV STYLE="visibility:hidden"></DIV>'
s+='<DIV ID="FlyLayer" STYLE="position:absolute; '
s+='top:-32; left:-32; width:32; height:32">'
s+=''
s+='<IMG NAME="fly" SRC="snoop.gif" border=0>'
s+='</A></DIV>'
document.writeln(s)
}
}
window.onload = ScriptSetup
ShowSnoop()
</SCRIPT>