+ Post New Thread
Results 1 to 9 of 9
Web Development Thread, Automatically refresh a webpage ONLY when content has changed? in Coding and Web Development; Hey there, I'm in the process of writing a simple digital signage application, which is essentially some javascript displaying in ...
  1. #1

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,067
    Thank Post
    209
    Thanked 430 Times in 310 Posts
    Rep Power
    144

    Automatically refresh a webpage ONLY when content has changed?

    Hey there,

    I'm in the process of writing a simple digital signage application, which is essentially some javascript displaying in a fullscreen webrowser which scrolls the contents of a HTML file up the screen. That side of it works well.

    I've also written a simple interface to update the contents.htm file using FCKeditor, but at the moment to get it to display the new contents requires a manual refresh of the webpage, which isn't ideal. (the screens for this are going to be fairly high up on a wall, and the PC is going to be the other side of the wall)

    What i'm looking for is some javascript or simelar which will automatically refresh the page only if the contents.htm file has been changed. Is this possible?

    I know I could use a set timed refresh on the page, say every 5 minutes, but the javascript takes a while to get going when you load the page, and I don't really want it doing this every 5 minutes if it can be helped. The contents are likely to only be updated once or twice a week.

    Any ideas gratefully received.

    Mike.

  2. #2
    Jona's Avatar
    Join Date
    May 2007
    Location
    Cranleigh
    Posts
    469
    Thank Post
    14
    Thanked 50 Times in 48 Posts
    Rep Power
    23
    perhaphs you could do it with AJAX?

  3. #3

    Join Date
    Jan 2008
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    You can do this within HTML. In between the <head></head> tags add the following

    <META HTTP-EQUIV="refresh" CONTENT="300">

    This will reload the page every 5 mintues, the CONTENT is in seconds, so you can change this accordinly.

    HTH

    Cheers

    N

  4. #4


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,692
    Thank Post
    352
    Thanked 797 Times in 716 Posts
    Rep Power
    347
    The OP specifically said he didn't want a timer like that.

    Mind you, I don't have a better solution other than suggesting a manual refresh if its only modified once or twice a week as opposed to making something complicated which needn't be.

  5. #5

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,647
    Thank Post
    1,256
    Thanked 781 Times in 678 Posts
    Rep Power
    236
    Quote Originally Posted by maniac View Post
    What i'm looking for is some javascript or simelar which will automatically refresh the page only if the contents.htm file has been changed. Is this possible?
    There's no need to refresh the whole page at all - simply have your controlling page re-load the contents.htm file every 5/10/whatever minutes. How are you loading content.htm into the containing page - are you loading it in to a hidden DIV element? If so, use a Javascript timer to delete the contents of that DIV periodically and load contents.htm again. Might even be simper to use a for loop - run 10 times around the loop, reload contents.htm, start again.

    --
    David Hicks

  6. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Ajax feels like the right answer (it's a good buzzword so it must be right :-))

    The other thing might be to have a script running which checks to see if there's new content every 5 minutes. If it finds new content then it refreshes the browser.

    Code below is not complete - I don't know how you will determine if there is new content but I'm guessing you'll query a database for a "last updated" field??

    Set oIE=createobject("internetexplorer.application")
    Do While (oIE.Busy)
    Wscript.Sleep 250
    Loop
    oIE.width=1024
    oIE.height=768
    oIE.left=0
    oIE.top=0
    oIE.visible=true
    oIE.navigate "http://server/sign.htm"

    do
    wscript.sleep 5*60*1000 ' sleep 5 minutes
    'code here to query database for new content
    if bNewContentFound then
    oIE.navigate "http://server.sign.htm"
    end if
    loop

  7. #7

    Join Date
    May 2014
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by dhicks View Post
    There's no need to refresh the whole page at all - simply have your controlling page re-load the contents.htm file every 5/10/whatever minutes. How are you loading content.htm into the containing page - are you loading it in to a hidden DIV element? If so, use a Javascript timer to delete the contents of that DIV periodically and load contents.htm again. Might even be simper to use a for loop - run 10 times around the loop, reload contents.htm, start again.

    --
    David Hicks



    Hello, I came across this post needing to solve this problem for myself and like your method rather then using ajax. I was wondering if you could point me to some example code maybe... and I apologize for my lack of skills in this area but since I'm literally hungry in this poor economy I'm forced to learn how everything at the same time with no time to primer. :-( I'm thinking this will work for what I'm needing to achieve transparently without the viewing end user visually seeing a full on reload were the content flashes away as everything loads in.
    Last edited by Little-Miss; 8th May 2014 at 01:00 AM. Reason: Language

  8. #8


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,026
    Thank Post
    231
    Thanked 2,699 Times in 1,994 Posts
    Rep Power
    792
    Knockout.js can automatically update a webpage without reloading the entire page.

    Example: Knockout.js Observable Arrays - CodePen

  9. Thanks to Arthur from:

    dhicks (8th May 2014)

  10. #9

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,647
    Thank Post
    1,256
    Thanked 781 Times in 678 Posts
    Rep Power
    236
    Quote Originally Posted by brokendash View Post
    Hello, I came across this post needing to solve this problem for myself and like your method rather then using ajax.
    If you have content in an iframe on a page that you need to reload periodically, you should simply be able to trigger a "reload" via Javascript / JQuery:

    javascript - Reload an iframe with jQuery - Stack Overflow

    Depending on how large that iframe is, the user might still see a section of the page disapear while it reloads - Knockout.js, as detailed above, might be more suitible for you situation.

SHARE:
+ Post New Thread

Similar Threads

  1. Group Policy Refresh Intervals.
    By boomam in forum Windows
    Replies: 12
    Last Post: 7th January 2008, 10:52 AM
  2. Automatically detect settings
    By techyphil in forum Windows
    Replies: 5
    Last Post: 26th November 2007, 09:28 PM
  3. AutoIt Script Help - Get Last Changed File
    By russdev in forum Scripts
    Replies: 8
    Last Post: 8th August 2007, 05:34 AM
  4. Defrag PC's automatically
    By TechSupp in forum How do you do....it?
    Replies: 8
    Last Post: 12th April 2007, 12:05 PM
  5. DHCP Refresh
    By Grommit in forum Windows
    Replies: 5
    Last Post: 4th December 2006, 10:55 AM

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
  •