Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you make an image fly across the screen please?

Status
Not open for further replies.

meeble

Programmer
Sep 24, 2002
137
GB
I want to use Javascript/DHTML to make an image go from right to left across the screen INSIDE a table which is 700px width.

Any ideas?

It has to work on IE/Netscape etc.

Cheers

James
 
Create a div and put your image inside it. Then reposition the div around the screen accordingly.

-kaht

banghead.gif
 
How you do make it move on its own though repeatedly?

Cheers

James
 
Hey, if you want it to just fly horizantaly- put the imgae between &quot;<marquee>&quot; and &quot;</marquee>&quot;. I think is should work also inside tables + you can adjust the marquee width and behavoir.
 
Thanks, but <marquee> doesn't work on earlier versions of Netscape or Internet Explorer on the Mac.

Any other ideas?

Many thanks

James
 
use what kaht wrote +
to automate it do:
var x;
function movediv()
{
//basicly here you change the div corodinations
//as if the starting place was x from left and y from top //now set x to x=x+1 and y to y=y+1 or in any other way
}
function repeat() // this repeats the movediv()
//to stop this use: 'event'=&quot;clearTimeout(x)&quot;;
{
x=setTimeout(&quot;movediv()&quot;,&quot;2000(//u changethe speed)&quot;)
}
 
Like this?

<html>
<head>

<script>
var x;
function movediv()
{
x=x+1;
y=y+1;
}
function repeat()

{
x=setTimeout(&quot;movediv()&quot;,&quot;2000(//u changethe speed)&quot;)
}
</script>
</head>

<body>

<div>hello</div>

</body>
</html>
 
If you change the x and y coordinates it'll move along a diagonal instead of horizontally. Also, there's more to the syntax than x = x + 1. I can't remember the syntax off the top of my head and I'm kinda busy to research it at the moment. Any google search should give you what you're looking for cause moving divs is pretty common.

-kaht

banghead.gif
 

James,

Check out my posting here: thread216-758315

This gives full source code to do what you're after.

You should be able to put an image in the div, instead of text.

Hope this helps,

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top