#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0

    Page Auto Refresh


    Hey,

    I am working on a page with several webcam shots that I need to automatically refresh. Obviously this can be done with the meta tag or javascript however:

    Some of the webcams shots load at different times, and some take up to a minute to come back. I would like the page to refresh every 10 seconds whether or not the page has "completely" loaded, is this possible?

    Thanks in advance for any help.
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,007
    Rep Power
    2791
    Welcome to DevShed, cstringy!

    Why do you imagine is it not possible? Have you run into issues? Which Javascript method have you tried?
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by Winters
    Welcome to DevShed, cstringy!

    Why do you imagine is it not possible? Have you run into issues? Which Javascript method have you tried?
    Thanks for responding, right now I am using:

    <script type="text/javascript">
    window.onload = setupRefresh;

    function setupRefresh() {
    setTimeout("refreshPage();", 5000); // milliseconds
    }
    function refreshPage() {
    window.location = location.href;
    </script>

    This is refreshing the page, but I am wondering if I can set like an actual timeout period (not dependent on the page fully loading)... The issue I am having is not being able to refresh the page every 10 seconds. If the page takes 30 seconds to load, I am stuck with a 40 second refresh. I guess this would be a JS question =\
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,007
    Rep Power
    2791
    Well, you are telling the script to run when the document finishes loading, so remove that and you should be good. The Javascript is in the HEAD tags?
    Javascript Code:
    setTimeout("refreshPage();", 10000);
     
    function refreshPage() {
    	window.location = location.href;
    }
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0
    YOU ARE THE GREATEST!!!

    Thank you so much, I am struggling to figure out how JS works so its hard to edit code I find... you just made my day.
  10. #6
  11. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,007
    Rep Power
    2791
    Glad you got it working
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.

IMN logo majestic logo threadwatch logo seochat tools logo