mossj (15th November 2009)
Is there any html code that people can kindly donate to me to refresh images in a html page? Not sure if its possible, I have a meta tag to refresh the whole page but when you scroll down it takes you back to the top when it refreshs...
I think the only way to stop this is refresh the images within the page rather that the page but any other ideas welcomed....
Thank you in advance.

You could set up a Javascript timer that changes the image. Give the image tag an ID that you can get Javascript to search for, then every time your timed function runs it simply goes an changes the "src" attribute of that image tag.
Edit: You might want to use a Javascript library such as JQuery to do the above, less messing around dealing with browser versions.
--
David Hicks
Last edited by dhicks; 12th November 2009 at 12:50 PM.
Had a quick go with it but im not good enough at coding to know what to do....
<IMG src="imgname.jpg" width="320" height="240" border="1" name="refresh">
<SCRIPT language="JavaScript" type="text/javascript">
<!--
var t = 1 // interval in seconds
image = "imaginname.jpg" //name of the image
function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp
setTimeout("Start()", t*1000)
}
Start();
// -->
</SCRIPT>

That chunk of code looked about right, did you try running it, see what happened? You might want to make the timer interval a bit longer, certainly to start with, just so you get a chance to see what is happening. Also, won't you need a list of images in an array or something somewhere?
--
David Hicks
tried running it but it did nothing, it had the picture in but did not update it... i am unsure about an array and where to put it?

Close, but this might work (untested):
Code:<IMG src="imgname.jpg" width="320" height="240" border="1" id="img"> <SCRIPT language="JavaScript" type="text/javascript"> <!-- var t = 1; var image = "imaginname.jpg"; function Start() { tmp = new Date(); tmp = "?"+tmp.getTime(); document.getElementById('img').src = image+tmp; } setInterval("Start()", t * 1000); // --> </SCRIPT>
mossj (15th November 2009)
still no luck, displays the picture but does not refresh... any other ideas?

I just put that on a page and it does seem to work - example here but with a different image loaded via the script to indicate that it has changed.
mossj (15th November 2009)
hmmm... I can see it working on your link....
Have posted my script left my file locations in so you can see if i am doing anything wrong...
<IMG src="\\server\Adult Resources\xp11.jpg" width="320" height="240" border="1" id="img">
<SCRIPT language="JavaScript" type="text/javascript">
<!--
var t = 3;
var image = "\\server\Adult Resources\xp11.jpg";
function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime();
document.getElementById('img').src = image+tmp;
}
setInterval("Start()", t * 1000);
// -->
</SCRIPT>
the image xp11.jpeg is changing every second, it is a webcam output picture thjat changes every second, if I f5 the webpage the picture changes?
I can't see anything wrong with the code whatsoever.
Make sure that the images url is different every time (check the properties).
It should be something like....
For Example:
xp11.jpg?1258360019056
then the number will be different on refresh:
xp11.jpg?1258360024056
Ensure it's actually different, if it IS, then the code is doing its refresh thang.

if i put in file:///server/Adult Resources/xp11.jpg it doesnt even display the picture in the webpage... ?
but if i put \\server\Adult Resources\xp11.jpg it works... just doesnt refresh
There are currently 1 users browsing this thread. (0 members and 1 guests)