Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I know basic html,
is there any way i can generate an html which has 4 images where image refreshes after every 5 seconds.

Thanks in advance
Posted
Comments
enhzflep 4-Apr-13 13:15pm    
I suspect it's not what you want, however, it is what you asked for.

"Yes"
fjdiewornncalwe 4-Apr-13 14:04pm    
My thoughts exactly.
Monster Maker 4-Apr-13 13:25pm    
do you need a slideshow?
srastogi85 4-Apr-13 13:27pm    
yes can say a sort of slideshow only as for each image time after which it should change will be defined

Try interval thing. Have a look at the Javascript setTimeout function:
Tutorial - Using setInterval and setTimeout[^]
Javascript Timers[^]
 
Share this answer
 
v2
Comments
fjdiewornncalwe 4-Apr-13 14:04pm    
+5. Probably what the OP is looking for.
Sergey Alexandrovich Kryukov 4-Apr-13 15:22pm    
Sure, a 5.
—SA
There are two ways:

  1. Animated GIF. Google a bit. My favorite image editor is GIMP (available for Linux and Windows at least), but you may prefer another. Basically, you create a repeating 'movie' that shows one frame every 5 seconds, and then loops back to the beginning.
  2. Use Javascript, see http://www.w3schools.com/js/js_timing.asp[^]; you may use setInterval(), and either replace the "src" attribute of a "img" tag, or (a little more advanced), change the style of the "img" to show different sprites. The idea is that if you have 4 images, each of them 200x100 pixels, you save them as a 200x400 bigger image, and you use css to change the offset of the visible part, like 'sliding' the image behind a viewport.

Your choice depends on the available tools (image editor), and your personal preference (do you want to sharpen your Javascript and CSS, or not).

Hope this helps,
Pablo.
 
Share this answer
 
Comments
Thomas Daniels 4-Apr-13 12:45pm    
Hi,
You posted a link to W3Schools. In my opinion, that's not a good idea. If you want to know why, have a look here: http://www.w3fools.com/[^]
I don't vote, because before I saw w3fools.com, I also posted links to W3Schools.
Pablo Aliskevicius 4-Apr-13 14:40pm    
Thanks for your comment; and more than that, thanks for the link!
Thomas Daniels 5-Apr-13 3:29am    
You're welcome!
Sergey Alexandrovich Kryukov 4-Apr-13 15:35pm    
Interesting site, thank you for sharing.
I also put referenced w3schools.com a lot, for their convenience, and do use some obsolete features like "big" tags. However, I think that even w3fools.com claims need checkup.
Also, even though the standardization is much better than the disaster of following ad-hoc needs, even the standards should not be taken as the ultimate authorities, because sometimes they contain some mistakes: inconsistencies or simply questionable features which are doomed to be deprecated in future. In particular, I feel somewhat suspicious about HTML5. A mere fact that it does not enforce well-formed XML (there is XHTML5) does not allow me to be 100% serious about it. And XML itself was found to have rough inconsistencies described in annotated XML reference (http://www.xml.com/axml/testaxml.htm)...
—SA
Thomas Daniels 5-Apr-13 3:30am    
Thanks for your explanation!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900