473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to force reload of "temperature.js" data

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
5 7793
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Eric | last post by:
Is it possible? I'm trying to add to the current page -- but add at a specific point. Can add HTML tags from javascript midway through the page (at a place I specify) without erasing the existing...
5
by: Charles Crume | last post by:
Hello all; I've been able to locate, and download, the source for "animate.js" from a number of web sites, but have not been able to find *any* documentation on this script. Does anyone have...
4
by: Dmitry | last post by:
Hello, Sometimes on js code execution Mozilla 1.5 prints in JS concole the following error: "Error: fn is not defined" where "fn" is the function name surely defined _before_ the line that...
10
by: Blue® | last post by:
I would like to call the content of content.htm (containing only HTML codes) into index.htm. This is usually done by renaming index.htm to index.shtml and use this tag: <!--#include...
7
by: RFS666 | last post by:
Hello, I would like to use variables with a type in jscript.NET. I declare them as follows: var x : double = 5.03; This doesn't work in my script, that I write to the page in codebehind with...
2
by: eschl | last post by:
Doesn't "prototype.js" support the "responseXML" property of the XMLHttpRequest object? var url = "test.jsp"; var pars = ""; var myAjax = new Ajax.Request(url, {method: 'get', parameters:...
1
by: santhoskumara | last post by:
suppose i have two javascript file, where my jsp page need both the .js file. how will i import to my page. whether i need to put a two script tag and mention the path value in the src attribute...
9
by: Mahernoz | last post by:
Hello Friends, The JavaScript File exmplmenu_var.js contains the code... (for the sake of brevity i am showing only that code which needs to be changed) I am actually developing a menu using...
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.