How can i...

admin

Administrator
Staff member
Hi,<br />
I suppose this is in the right section...<br />
<br />
I'm having trouble with my javascript which revoles around the mouse, because I use frames my page won't allow me to let it carry on to the next page/frame. Is there any one that will help, here's th script if u need to see it.<br />
<br />
<script language="JavaScript"><br />
<!--<br />
colour='#00ff00';<br />
size=50;<br />
n6=(document.getElementById&&!document.all);<br />
ns=(document.layers);<br />
ie=(document.all);<br />
d=(ns||ie)?'document.':'document.getElementById("';<br />
a=(ns||n6)?'':'all.';<br />
n6r=(n6)?'")':'';<br />
s=(ns)?'':'.style';<br />
dy=new Array();<br />
dx=new Array();<br />
cstep=0;<br />
step=0.2;<br />
xpos=0;<br />
ypos=0;<br />
<br />
n=(n6)?5:7;<br />
if (ns){<br />
for (i = 0; i < n; i++){<br />
document.write('<layer name=x'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+colour+'></layer>');<br />
document.write('<layer name=y'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+colour+'></layer>');<br />
document.write('<layer name=z'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+colour+'></layer>');<br />
}<br />
}<br />
if (ie)<br />
document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');<br />
if (ie||n6){<br />
for (i = 0; i < n; i++){<br />
document.write('<div id=x'+i+' style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+colour+';font-size:'+i/2+'"></div>');<br />
document.write('<div id=y'+i+' style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+colour+';font-size:'+i/2+'"></div>');<br />
document.write('<div id=z'+i+' style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+colour+';font-size:'+i/2+'"></div>');<br />
}<br />
}<br />
if (ie)<br />
document.write('</div></div>');<br />
<br />
(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;<br />
function Mouse(evnt){<br />
xpos= (ns||n6)?evnt.pageX+6:event.x+6;<br />
ypos= (ns||n6)?evnt.pageY+16 - window.pageYOffset:event.y+16;<br />
}<br />
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;<br />
<br />
function leaders(){<br />
e=360/3;<br />
for (i = 0; i < 3; i++){<br />
dy=ypos+size*Math.cos(cstep+i*e*Math.PI/180)*Math.sin((cstep+i*25)/2);<br />
dx=xpos+size*Math.sin(cstep+i*e*Math.PI/180)*Math.sin((cstep+i*25)/2)*Math.sin(cstep/4);<br />
}<br />
cstep+=step;<br />
setTimeout('leaders()',10);<br />
}<br />
<br />
function assign(){<br />
f=(ns||n6)?window.pageYOffset:0;<br />
if (ie)con.style.top=document.body.scrollTop;<br />
for (i = 0; i < n; i++){<br />
var temp1 = eval(d+a+"x"+i+n6r+s);<br />
var temp2 = eval(d+a+"y"+i+n6r+s);<br />
var temp3 = eval(d+a+"z"+i+n6r+s);<br />
if (i < n-1){<br />
var temp4 = eval(d+a+"x"+(i+1)+n6r+s);<br />
var temp5 = eval(d+a+"y"+(i+1)+n6r+s);<br />
var temp6 = eval(d+a+"z"+(i+1)+n6r+s);<br />
temp1.top = parseInt(temp4.top);<br />
temp1.left = parseInt(temp4.left);<br />
temp2.top = parseInt(temp5.top);<br />
temp2.left = parseInt(temp5.left);<br />
temp3.top = parseInt(temp6.top);<br />
temp3.left = parseInt(temp6.left);<br />
} <br />
else{<br />
temp1.top=dy[0]+f;temp1.left=dx[0];<br />
temp2.top=dy[1]+f;temp2.left=dx[1];<br />
temp3.top=dy[2]+f;temp3.left=dx[2];<br />
}<br />
}<br />
setTimeout("assign()",10);<br />
}<br />
function Start(){<br />
leaders();<br />
assign();<br />
}<br />
window.onload=Start;<br />
// --><br />
</script><!--content-->I would tink the best way to do it is to have a div over each page that runs the script whenever you mouse over it and when you move your mouse off it does an on mouseout event to stop the script. not that i know how but it is an idea.<!--content-->I would think that putting the script inside all of the pages which are shown in the frames, would work.<!--content-->try putting your js into a single file and call it with a url on each page that will be using it.<br />
<br />
The .js file is a single, text only, no headings file. Just cut and past all your js into it and name it whatever.js...do NOT use script tags in this file! upload to the directory where your pages are that will be calling it.<br />
Oh, yeah, leave off the comment tags also, <!---and the //--><br />
THEN....<br />
inside the head tags <br />
<br />
<head><br />
<br />
<script language="JavaScript"<br />
src=http://www.htmlforums.com/archive/index.php/"whatever.js"<br />
type="text/javascript"></script><br />
<br />
</head><br />
<br />
Put this in all the pages that will be calling the .js file.<br />
<br />
<br />
Hope that helps,<br />
<br />
Ann<!--content-->Thx for the help!<!--content-->
 
Back
Top