Jump to content

Recommended Posts

Posted

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.

Posted (edited)
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...

 

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

Edited by dhicks
Posted
Had a quick go with it but im not good enough at coding to know what to do...

 

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

Posted
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?
Posted

Close, but this might work (untested):

 

imgname.jpg 
 <br />
<!-- <br />
var t = 1;<br />
var image = "imaginname.jpg";<br />
<br />
function Start() { <br />
    tmp = new Date();<br />
    tmp = "?"+tmp.getTime();<br />
    document.getElementById('img').src = image+tmp;<br />
} <br />
<br />
setInterval("Start()", t * 1000);<br />
// --> <br />

  • Thanks 1
Posted

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...

 

\\server\Adult Resources\xp11.jpg

Posted

Its refreshing to the same image, so you will not see anything change. You would need to put a different image name in where you have var image = "\\server\Adult Resources\xp11.jpg";

 

Steve

 

 

 

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...

 

\\server\Adult Resources\xp11.jpg

Posted
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.

 

Thanks for that webman, okay to use it in a commercial enviroment?

Posted
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?
Posted

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.

Posted
Thanks for that webman, okay to use it in a commercial enviroment?

 

Sure, although I just slightly modified the original post by neon.

 

@neon: Instead of using UNC paths, try using this:

 

file:///server/Adult Resources/xp11.jpg

Posted

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

Posted (edited)
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

 

OK. Are you sure the picture itself is changing? If you change the initial img src to another (but leave the javascript reference the same), completely different picture, do you see it change?

 

EDIT: Try this in the javascript part:

 

var image = "\\\\server\\Adult Resources\\xp11.jpg";

Edited by webman
Posted
The image is definatly changing, I have it set up exactly as I want with the image at the top of the page refreshing (using metatag) however when you scroll down the page becasue it is refreshing the whole page it takes you back up to the top, thats why I only want to refresh the picture not the whole page... I will give the \\\\server a go and let you know.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...