By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

How to force reload of "temperature.js" data

P: n/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.

Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <I_*********************@news1.calgary.shaw.ca>,
Derek Ross <dr***@iders.ca> 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()
Jul 20 '05 #2

P: n/a
In article <ri****************************@news.so-net.com.hk>,
Chris Riesbeck <ri******@cs.northwestern.edu> 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.
Jul 20 '05 #3

P: n/a
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 <dr***@iders.ca> wrote in message news:<I_*********************@news1.calgary.shaw.c 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.

Jul 20 '05 #4

P: n/a
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" <dr***@iders.ca> wrote in message news:I_*********************@news1.calgary.shaw.ca ...
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.


Jul 20 '05 #5

P: n/a
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.

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.