The following is javascript
function show(layername){
if (!) return false;
if (!(layername)) return false;
var layer = (layername);
= "0px";
= "0px";
= "block";
movement = setTimeout("animation()",0)
}
function animation(){
if (!) return false;
if (!(layername)) return false;
var layer = (layername);
var xpos = parseInt();
var ypos = parseInt();
if (xpos == 480 && ypos == 80){
return true;
}
if (xpos < 480){
xpos+=10
}
if (xpos > 480){
xpos-=10
}
if (ypos < 80){
ypos+=10
}
if (ypos > 80){
ypos-=10
}
= xpos + "px";
= ypos + "px";
movement = setTimeout("animation()",0);
}
The following is html
<div id="">
<ul>
<li > <a href="#" onmouseover="show('layer1');">My friend</a></li>
<li > <a href="#" onmouseover="show('layer2');">My information</a></li>
<li > <a href="#" onmouseover="show('layer3');">My album</a></li>
<li > <a href="#" onmouseover="show('layer4');">My article</a></li>
</ul>
</div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
question
If you use parameters layer1, layer2, layer3, layer4, it will not succeed every time, and the prompt 'layername' is undefined
If you change the layername in javascript to the id value of the div, it will be successful, but if so, the javascript program will have many
How can I use the parameter form correctly?
Solution:
movement = setTimeout("animation()",0)
This place does not pass parameters to animation()
The defined animation() function does not accept parameters, but also uses
var layer = (layername);
Receive layername variable
Misunderstood closure? Want to receive parameters from the function show(layername) function? ? ?
The timer doesn't seem to work at all
function show(layername){
if (!) return false;
if (!(layername)) return false;
var layer = (layername);
= "0px";
= "0px";
= "block";
movement = setTimeout("animation()",0)
}
function animation(){
if (!) return false;
if (!(layername)) return false;
var layer = (layername);
var xpos = parseInt();
var ypos = parseInt();
if (xpos == 480 && ypos == 80){
return true;
}
if (xpos < 480){
xpos+=10
}
if (xpos > 480){
xpos-=10
}
if (ypos < 80){
ypos+=10
}
if (ypos > 80){
ypos-=10
}
= xpos + "px";
= ypos + "px";
movement = setTimeout("animation()",0);
}
The following is html
<div id="">
<ul>
<li > <a href="#" onmouseover="show('layer1');">My friend</a></li>
<li > <a href="#" onmouseover="show('layer2');">My information</a></li>
<li > <a href="#" onmouseover="show('layer3');">My album</a></li>
<li > <a href="#" onmouseover="show('layer4');">My article</a></li>
</ul>
</div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
<div class="clearfloat"> </div>
question
If you use parameters layer1, layer2, layer3, layer4, it will not succeed every time, and the prompt 'layername' is undefined
If you change the layername in javascript to the id value of the div, it will be successful, but if so, the javascript program will have many
How can I use the parameter form correctly?
Solution:
movement = setTimeout("animation()",0)
This place does not pass parameters to animation()
The defined animation() function does not accept parameters, but also uses
var layer = (layername);
Receive layername variable
Misunderstood closure? Want to receive parameters from the function show(layername) function? ? ?
The timer doesn't seem to work at all