+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Coding Thread, Html coding in Coding and Web Development; Is there any html code that people can kindly donate to me to refresh images in a html page? Not ...
  1. #1
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15

    Html coding

    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.

  2. #2

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,683
    Thank Post
    1,268
    Thanked 789 Times in 686 Posts
    Rep Power
    237
    Quote Originally Posted by neon View Post
    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
    Last edited by dhicks; 12th November 2009 at 11:50 AM.

  3. #3
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    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>

  4. #4

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,683
    Thank Post
    1,268
    Thanked 789 Times in 686 Posts
    Rep Power
    237
    Quote Originally Posted by neon View Post
    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

  5. #5
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    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?

  6. #6

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    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>

  7. Thanks to webman from:

    mossj (15th November 2009)

  8. #7
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    still no luck, displays the picture but does not refresh... any other ideas?

  9. #8

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    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.

  10. Thanks to webman from:

    mossj (15th November 2009)

  11. #9
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    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>

  12. #10
    Devontechie's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    902
    Thank Post
    181
    Thanked 201 Times in 164 Posts
    Rep Power
    72
    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



    Quote Originally Posted by neon View Post
    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>

  13. #11
    mossj's Avatar
    Join Date
    Dec 2008
    Location
    Leicester
    Posts
    1,466
    Thank Post
    157
    Thanked 189 Times in 174 Posts
    Rep Power
    52
    Quote Originally Posted by webman View Post
    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?

  14. #12
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    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?

  15. #13
    Friez's Avatar
    Join Date
    Dec 2006
    Posts
    839
    Thank Post
    22
    Thanked 22 Times in 21 Posts
    Rep Power
    23
    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.

  16. #14

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    Quote Originally Posted by mossj View Post
    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:

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

  17. #15
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    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

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Coding C# for kids
    By garethedmondson in forum General Chat
    Replies: 6
    Last Post: 14th October 2009, 04:10 PM
  2. HTML Coding: ‘Do You Want To Close This Window?’
    By DaveP in forum How do you do....it?
    Replies: 2
    Last Post: 16th July 2008, 02:10 PM
  3. Need some Coding
    By russdev in forum Web Development
    Replies: 5
    Last Post: 11th November 2006, 10:49 PM
  4. Windows Mobile Coding
    By plexer in forum Coding
    Replies: 4
    Last Post: 24th June 2006, 07:55 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •