P
papa
Hello everyone!
I am trying to create a script that makes a text move first to the
right side of the screen and then back to the left side but I do not
accomplish this. My idea is to kick start the script by calling the
starta() -method witch in turn will start the moveTxt() and moveBack()
methods. If I remove the moveBack() method from the starta() -method
the script works so far as it is moving the text to the right side of
the screen. When I add the moveBack() method to the starta() -method
nothing works.
Do anyone have a solution to this problem? I attach the code below.
Best regards!
<html>
<head>
<title>en enkel animering</title>
<script language="JavaScript">
<!--
function starta()
{
moveTxt();
moveBack();
}
function moveTxt()
{
if(ani1.style.pixelLeft < 250)
{
ani1.style.pixelLeft += 2;
setTimeout("moveTxt()", 25);
}
}
function moveBack()
{
if(ani1.style.pixelLeft >= 10)
{
ani1.style.pixelLeft -= 2;
setTimeout("moveBack()", 25);
}
}
-->
</script>
</head>
<body onLoad="starta()">
<div id="ani1" style="position: absolute; left:10; top:10">
Text ... som flyttas!
</div>
</body>
</html>
I am trying to create a script that makes a text move first to the
right side of the screen and then back to the left side but I do not
accomplish this. My idea is to kick start the script by calling the
starta() -method witch in turn will start the moveTxt() and moveBack()
methods. If I remove the moveBack() method from the starta() -method
the script works so far as it is moving the text to the right side of
the screen. When I add the moveBack() method to the starta() -method
nothing works.
Do anyone have a solution to this problem? I attach the code below.
Best regards!
<html>
<head>
<title>en enkel animering</title>
<script language="JavaScript">
<!--
function starta()
{
moveTxt();
moveBack();
}
function moveTxt()
{
if(ani1.style.pixelLeft < 250)
{
ani1.style.pixelLeft += 2;
setTimeout("moveTxt()", 25);
}
}
function moveBack()
{
if(ani1.style.pixelLeft >= 10)
{
ani1.style.pixelLeft -= 2;
setTimeout("moveBack()", 25);
}
}
-->
</script>
</head>
<body onLoad="starta()">
<div id="ani1" style="position: absolute; left:10; top:10">
Text ... som flyttas!
</div>
</body>
</html>