|
-
Nov 25th, 2003, 02:27 PM
#1
Thread Starter
Fanatic Member
setInterval??
whats wrong with the following script..it is supposed to move 50px in every 2 seconds but there is an error!!
please tell me more on "setInterval"..thanks
<html>
<head>
<script>
a=setInterval('Moveit()',2000);
function moveit()
{
text1.style.posLeft=text1.style.posLeft+50;
}
</script>
</head>
<body onload="moveit()">
<input type=text style="position:absolute" name=text1 id=text1>
</body>
</html>
-
Nov 25th, 2003, 02:57 PM
#2
Javascript's case sensitive :
a=setInterval('Moveit()',2000);
Although - this would be slightly better:
Code:
<html>
<head>
<script language="javascript" type="text/javascript">
a = setInterval('moveit()',2000);
function moveit()
{
var target = document.getElementById("text1");
if (target != null) {
target.style.posLeft += 50;
}
}
</script>
</head>
<body>
<input type="text" style="position: absolute;" name="text1" id="text1">
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|