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();" />
Questions about programming languages and debugging
2 posts • Page 1 of 1
- Ph. D. in Sucko'logics
- Posts: 315
- Joined: 06 Mar 2006, 17:00
- Location: Belgistahn
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.
If you want images to show up randomly, use REAL integers, not floating decimals and put them BEFORE the extention like here :
assuming you have at least ten images stocked in that same directory.
Code: Select all
(img src="/path/to/pic/pic.1jpg" onclick="this.src='/path/to/another/pic/'+Math.floor(Math.random()*10)'+'.jpg'" )