Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to force reload of "temperature.js" data

Reply
Thread Tools

How to force reload of "temperature.js" data

 
 
Derek Ross
Guest
Posts: n/a
 
      09-18-2003
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.

 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      09-18-2003
In article <I_kab.174037$(E-Mail Removed)>,
Derek Ross <(E-Mail Removed)> 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()
 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      09-18-2003
In article <(E-Mail Removed)-net.com.hk>,
Chris Riesbeck <(E-Mail Removed)> 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.
 
Reply With Quote
 
Bernard Lechler
Guest
Posts: n/a
 
      09-18-2003
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 <(E-Mail Removed)> wrote in message news:<I_kab.174037$(E-Mail Removed) a>...
> 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.

 
Reply With Quote
 
Csaba2000
Guest
Posts: n/a
 
      09-18-2003
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" <(E-Mail Removed)> wrote in message news:I_kab.174037$(E-Mail Removed) ...
> 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.




 
Reply With Quote
 
Derek Ross
Guest
Posts: n/a
 
      09-19-2003
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM



Advertisments