PDA

View Full Version : can a mouse tail be disabled?


Talita
10-06-2002, 10:18 AM
I have included a spiraling mouse tail in one of my web pages, however I feel that this may be irritating to some users of the page, so I would like to be able to disable (and for that matter re enable) the mouse tail script by having the user click on a button on the page.

Could anyone assist me with this? I am not sure how to go about enabling and disabling the script.

scroots
10-06-2002, 10:33 AM
could you post your script so people can take a look.

scroots

Talita
10-06-2002, 10:37 AM
Sorry, I forgot to include the script, here it is:

<script>

B=document.all;
C=document.layers;
T1=new Array("images/mouse/butterfly3.gif",30,28, "images/mouse/butterfly3.gif",30,28,"images/mouse/butterfly3.gif",30,28,"images/mouse/butterfly3.gif",30,28,"images/mouse/butterfly3.gif",30,28)
nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;
for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}
function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}
function closeContainer(){
document.write((B)?"</div>":"</layer>")
}
function getXpos(N){
return (B) ? parseInt(B[N].style.left) : C[N].left
}
function getYpos(N){
return (B) ? parseInt(B[N].style.top) : C[N].top
}

function moveContainer(N,DX,DY){
c=(B) ? B[N].style :C[N];c.left=DX;c.top=DY
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}
function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2
)
}
if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
</script>

glenngv
10-07-2002, 04:09 AM
function cycle(){
if (!showTail) return;
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}

function newPos(e){
if (!showTail) return;
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2
)
}

var showTail = true; //global variable that tells when to show mouse tail

function showHideTail(objChk){
showTail = (objChk.checked) ? false:true;
}


if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)


then in the form, create a checkbox:

<input type="checkbox" name="chkTail" onclick="showHideTail(this)">Hide Mouse Tail

Talita
10-07-2002, 06:40 AM
Thankyou so much Glenn for helping me with my code! It works perfectly!

Thanks again.

Talita