This code is suposed to download a picture from a site in an endless loop, but i tested it on my own site then i checked my apache logs and it says the picture only was downloaded once.
<img width="100" height="100" src="http://site/image.jpg" onload="this.src=http://site/image.jpg?' + Math.random();" />
DL Image endless loop?
- FrankB
- Ph. D. in Sucko'logics
- Posts: 315
- Joined: 06 Mar 2006, 17:00
- 18
- Location: Belgistahn
- Contact:
Re: DL Image endless loop?
No it doesn't, the script is :neo130 wrote:This code is suposed to download a picture from a site in an endless loop]
1. completely wrong.
2. only executed once.
Well, what did you expect ??? (you asked the browser to load the page and picture only once also. So..)neo130 wrote: but i tested it on my own site then i checked my apache logs and it says the picture only was downloaded once.
Aw.. bad bad code.neo130 wrote: <img width="100" height="100" src="http://site/image.jpg" onload="this.src=http://site/image.jpg?' + Math.random();" />
If you want images to show up randomly, use REAL integers, not floating decimals and put them BEFORE the extention like here :
Code: Select all
(img src="/path/to/pic/pic.1jpg"
onclick="this.src='/path/to/another/pic/'+Math.floor(Math.random()*10)'+'.jpg'" )