How to force reload of "temperature.js" data

Discussion in 'Javascript' started by Derek Ross, Sep 18, 2003.

  1. Derek Ross

    Derek Ross Guest

    Hello,

    Say I have a server that's saving the CPU temperature to
    'temperature.js' once a second. The contents of the file is one single
    line:

    var temperature = "35.5";

    And it changes as the temperature changes.

    Is it possible to have an HTML file in the same directory as the
    "temperature.js" file, that's reading the file once a second and then
    provides a crude realtime update of the temperature value?

    The HTML result would look something like:

    TEMPERATURE:
    35.5
    35.6
    35.4
    35.7
    36.1
    ....etc, page continues appending temperature by the second...

    I know how to used .innerHTML to append values to a list, but I'm having
    trouble getting my "temperature.js" script to reload and execute once a
    second, so that the "temperature" variable is always up-to-date. It
    seems that the temperature is reloaded only when the whole HTML page is
    loaded.

    Any assistance would be appreciated,
    Thanks,
    Derek.
     
    Derek Ross, Sep 18, 2003
    #1
    1. Advertising

  2. In article <I_kab.174037$>,
    Derek Ross <> wrote:


    > I know how to used .innerHTML to append values to a list, but I'm having
    > trouble getting my "temperature.js" script to reload and execute once a
    > second, so that the "temperature" variable is always up-to-date. It
    > seems that the temperature is reloaded only when the whole HTML page is
    > loaded.


    Try

    <script ... id="data" src="temperatures.js"></script>

    To reload

    document.getElementById("data").src = "temperatures.js"

    To do this periodically, use setTimeOut()
     
    Chris Riesbeck, Sep 18, 2003
    #2
    1. Advertising

  3. In article <-net.com.hk>,
    Chris Riesbeck <> wrote:

    > Try
    >
    > <script ... id="data" src="temperatures.js"></script>
    >
    > To reload
    >
    > document.getElementById("data").src = "temperatures.js"


    Tested a bit more -- this only seems to work in IE,
    not Mozilla or Opera

    So follow the usual hack and a frameset with an invisible
    frame with an HTML file that loads the javascript, and
    then reload that frame as needed.
     
    Chris Riesbeck, Sep 18, 2003
    #3
  4. I would create a page with two frames. A main frame and a hidden
    frame. The hidden frame would have an onload event handler that
    appends the temperature to the document displayed in the main frame.
    It would then pause for an arbitrary period, and reload itself.

    Bernie

    Derek Ross <> wrote in message news:<I_kab.174037$>...
    > Hello,
    >
    > Say I have a server that's saving the CPU temperature to
    > 'temperature.js' once a second. The contents of the file is one single
    > line:
    >
    > var temperature = "35.5";
    >
    > And it changes as the temperature changes.
    >
    > Is it possible to have an HTML file in the same directory as the
    > "temperature.js" file, that's reading the file once a second and then
    > provides a crude realtime update of the temperature value?
    >
    > The HTML result would look something like:
    >
    > TEMPERATURE:
    > 35.5
    > 35.6
    > 35.4
    > 35.7
    > 36.1
    > ...etc, page continues appending temperature by the second...
    >
    > I know how to used .innerHTML to append values to a list, but I'm having
    > trouble getting my "temperature.js" script to reload and execute once a
    > second, so that the "temperature" variable is always up-to-date. It
    > seems that the temperature is reloaded only when the whole HTML page is
    > loaded.
    >
    > Any assistance would be appreciated,
    > Thanks,
    > Derek.
     
    Bernard Lechler, Sep 18, 2003
    #4
  5. Derek Ross

    Csaba2000 Guest

    One approach was covered in this newsgroup 2 days ago under the title:
    How to hit a server in the background
    If you can't find it, do a search on google - it's already there.

    In your case, since you're only returning a single datum, I'd
    be highly inclined to test out whether cookies load with .js files
    Please do report back if you go this route.

    Good Luck,
    Csaba Gabor from New York


    "Derek Ross" <> wrote in message news:I_kab.174037$...
    > Hello,
    >
    > Say I have a server that's saving the CPU temperature to
    > 'temperature.js' once a second. The contents of the file is one single
    > line:
    >
    > var temperature = "35.5";
    >
    > And it changes as the temperature changes.
    >
    > Is it possible to have an HTML file in the same directory as the
    > "temperature.js" file, that's reading the file once a second and then
    > provides a crude realtime update of the temperature value?
    >
    > The HTML result would look something like:
    >
    > TEMPERATURE:
    > 35.5
    > 35.6
    > 35.4
    > 35.7
    > 36.1
    > ...etc, page continues appending temperature by the second...
    >
    > I know how to used .innerHTML to append values to a list, but I'm having
    > trouble getting my "temperature.js" script to reload and execute once a
    > second, so that the "temperature" variable is always up-to-date. It
    > seems that the temperature is reloaded only when the whole HTML page is
    > loaded.
    >
    > Any assistance would be appreciated,
    > Thanks,
    > Derek.
     
    Csaba2000, Sep 18, 2003
    #5
  6. Derek Ross

    Derek Ross Guest

    Thank you for the advice.

    FWIW, I've also had some success with calling the js script in a
    popunder window, but I think I'll go with the frameset idea. Many
    people disable popups, which would pose a problem for me.

    Derek.
     
    Derek Ross, Sep 19, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sia Jai Sung

    Force reload of ASP page after processing

    Sia Jai Sung, Jan 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    8,199
  2. matt
    Replies:
    1
    Views:
    4,009
    Steve Drake
    Mar 3, 2004
  3. Joshua Beall
    Replies:
    26
    Views:
    222,744
    AndreiKaa
    Jun 29, 2007
  4. gen_tricomi
    Replies:
    2
    Views:
    788
    gen_tricomi
    May 23, 2006
  5. Stefan Mueller
    Replies:
    4
    Views:
    321
    Stefan Mueller
    Nov 5, 2005
Loading...

Share This Page