SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member Gearacid's Avatar
    Join Date
    Apr 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face How to make a div reload every ten seconds?

    Hey everyone...
    I've been web designer for a while now, but I never quite mastered Javascript.
    Is there any way I can have a div to be reloaded every ten seconds using JS?

    (Note: I already tried Google)

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is inside the DIV? An iframe?

    This is possible - it would just be useful to have some more info...
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Member Gearacid's Avatar
    Join Date
    Apr 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well there is some JS code in the div which needs to refreshed - without refreshing the whole page

  4. #4
    SitePoint Evangelist Alluvian's Avatar
    Join Date
    Jan 2007
    Location
    Orlando, FL
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could the code be put in a function and then have that function called every X milliseconds with setTimeout?

    PHP Code:
    <div>
    <
    script>
    function 
    runme(){
    // code here
    setTimeout("runme()",10000);
    }
    setTimeout("runme()",10000);
    </script>
    </div> 
    The code in the 'runme' function' will infinitely re-run every 10 seconds.

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - get new div contents using ajax every x seconds
    - write it to existing div.

    Since you're updating javascript, I'd suggest you use a library that supports adding scripts to the document via ajax (prototype.js for example)


Bookmarks

Posting Permissions

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