473,326 Members | 2,133 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,326 software developers and data experts.

DisplayTimeInStatusLine() - Help

Using Microsof Front Page, I am trying to display the time on the
Status Line, however, to no avail.
Here is a snip of the code code:
...\dev\JavaScript\DisplayTimeInStatusLine.js
<HTML>
<HEAD>
<script type="text/javascript">
//This function displays the time in the status line
//Invoke it once tho activate the clock; it will call itself from then
on.
function DisplayTimeInStatusLine(){
var d = new Date; //Get current time
var h = d.getHour; //Extract hours: 0 to 23
var m = d.getMinutes(); //Extract minutes: 0 to 59
var ampm = (h >= 12)?"PM":"AM"; //Is it am or pm
if(h > 12) h -= 12; //Convert 24-hour to 12-hour
if(h == 0) h = 12; //Convert 0 o'clock to midning
if(m < 10) m = "0" + m; //Convert 0 mins to 00 mins,etc
var t = h + ":" + m + ' ' + ampm; //Put it all together

defaultStattus = t; // Display it in the status line

// Arrange to do it all again in 1 min
setInterval(DisplayTimeInStatusLine(), 60000);
}
</SCRIPT>
</HEAD>
</HTML>
---------- end of snip 1 --------

...\dev\index.html
<head>
<!-- saved from url=(0014)about:internet -->
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Jamiil's Home Page</title>
<SCRIPT SRC="JavaScript/DisplayTimeInSatatusLine.js"></SCRIPT>
</head>

<body bgcolor="#000000" style="text-align: left"
onLoad="DisplayTimeInStatusLine();">
......
----- end of snip 2 -----

I am learning from a book called "JavaScript, The Definitive Guide, 3rd
Edition" by O'REILLY.

Can anyone help?

TIA

May 10 '06 #1
5 1216
Jamiil wrote:
Using Microsof Front Page, I am trying to display the time on the
Status Line, however, to no avail.
Here is a snip of the code code:
..\dev\JavaScript\DisplayTimeInStatusLine.js
<HTML>
<HEAD>
<script type="text/javascript">
//This function displays the time in the status line
//Invoke it once tho activate the clock; it will call itself from then
on.
function DisplayTimeInStatusLine(){
It is a convention that only constructors start with a capital letter,
so make that:

function displayTimeInStatusLine(){

var d = new Date; //Get current time
You want to call Date as a constructor function, so add '()':

var d = new Date();

var h = d.getHour; //Extract hours: 0 to 23
getHours() (note the 's') is a method of a date object, so it needs ()
to call it:

var h = d.getHours(); //Extract hours: 0 to 23

var m = d.getMinutes(); //Extract minutes: 0 to 59
var ampm = (h >= 12)?"PM":"AM"; //Is it am or pm
if(h > 12) h -= 12; //Convert 24-hour to 12-hour
if(h == 0) h = 12; //Convert 0 o'clock to midning
if(m < 10) m = "0" + m; //Convert 0 mins to 00 mins,etc
var t = h + ":" + m + ' ' + ampm; //Put it all together

defaultStattus = t; // Display it in the status line

// Arrange to do it all again in 1 min
setInterval(DisplayTimeInStatusLine(), 60000);


The first argument to setInterval should be a string. Your function
will execute displayTimeInStatusLine() zillions of times per second -
but you will only notice that your browser runs slowly. All the CPU is
being sucked-up by calls to DisplayTimeInStatusLine():

setInterval('displayTimeInStatusLine()', 60000);
Incidentally, that will likely slowly drift off the correct time so that
it is either + or - 1 minute from the 'correct' system time - say you
start it one second before 3:05 pm, it won't call the function again
until one second before 3:06, so when it shows 3:06 it will be 3:07.

But in any case, many browsers (including mine) will not let you change
the status bar text with script, so you've totally wasted your time -
but hey, for the purpose of the demo...

[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.com/faq/>
May 10 '06 #2
Thanks everyone for the prompt help!
I did all the changes you folks suggested, but I still get one error in
Line 1 says the popup window.
Here is the new encarnation of the code

--- Snipt of code in .\dev\index.html ---

<%@ Language=JavaScript %>
<html>
<head>
<!-- saved from url=(0014)about:internet -->
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Jamiil's Home Page</title>
<SCRIPT SRC=".\JavaScript\DisplayTimeInSatatusBar.js"></SCRIPT>
</head>

--- Snip in .\dev\JavaScript\DisplayTimeInStatusBar.js
<HTML>
<HEAD>
<script type="text/javascript">
//This function displays the time in the status line
//Invoke it once tho activate the clock; it will call itself from then
on.
function displayTimeInStatusBar(){
var d = new Date(); //Get current time
var h = d.getHour(); //Extract hours: 0 to 23
var m = d.getMinutes(); //Extract minutes: 0 to 59
var ampm = (h >= 12)?"PM":"AM"; //Is it am or pm
if(h > 12) h -= 12; //Convert 24-hour to 12-hour
if(h == 0) h = 12; //Convert 0 o'clock to midning
if(m < 10) m = "0" + m; //Convert 0 mins to 00 mins,etc
var t = h + ":" + m + ' ' + ampm; //Put it all together

defaultStatus = t; // Display it in the status line

// Arrange to do it all again in 1 min
setInterval('displayTimeInStatusBar()', 60000);
}
</SCRIPT>
</HEAD>
</HTML>

Should I use tags in this file? is this OK?

Thanks

May 10 '06 #3
Jamiil said the following on 5/10/2006 9:40 AM:
Thanks everyone for the prompt help!
I did all the changes you folks suggested, but I still get one error in
Line 1 says the popup window.
Here is the new encarnation of the code

--- Snipt of code in .\dev\index.html ---

<%@ Language=JavaScript %>
<html>
<head>
<!-- saved from url=(0014)about:internet -->
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Jamiil's Home Page</title>
<SCRIPT SRC=".\JavaScript\DisplayTimeInSatatusBar.js"></SCRIPT>
</head>

--- Snip in .\dev\JavaScript\DisplayTimeInStatusBar.js
<HTML>


syntax error. The only thing that goes in the external file is script
code, no tags. But you will still get an error unless you made a mistake
in your copy/paste. Your script tag references .\JavaScript.... but you
say it is in .\dev\JavaScript\... Those are not the same paths. And IE
will use a standard 404 page for the script source and again generate
errors.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 10 '06 #4
Thanks for your prompt response Randy,
the tree directory looks like this
c:\dev\index.html
c:\dev\sound\sound_files.wav
c:\dev\JavaScript\DisplayTimeInStatusBar.js
......
When including the *.js, I used relative address
<html>
<head>
....
<SCRIPT SRC="JavaScript\DisplayTimeInSatatusBar.js"></SCRIPT>
</head>
..
I don't see a problem with this statement, however, I have been proven
wrong more than once.
Could you please elaborate a bit more on this issue?
And yes, you are rihgt! I still get the runtime error!!

TIA

May 12 '06 #5
Jamiil said the following on 5/12/2006 7:08 AM:
Thanks for your prompt response Randy,
Thank you for quoting in the future.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
the tree directory looks like this
c:\dev\index.html
c:\dev\sound\sound_files.wav
c:\dev\JavaScript\DisplayTimeInStatusBar.js
......
When including the *.js, I used relative address
<html>
<head>
....
<SCRIPT SRC="JavaScript\DisplayTimeInSatatusBar.js"></SCRIPT>
That is not what you posted the first time though. But even then,
..\JavaScript and JavaScript are not the same path. For testing purposes,
put your .js file in the same folder. Resolve any and all errors, then
move it to the folder. Then, if you get errors you know it is a file
reference error. Is that the way your file is named as well? When
testing locally IE doesn't care about case, it will matter on a live
website though.
</head>
..
I don't see a problem with this statement, however, I have been proven
wrong more than once.
Could you please elaborate a bit more on this issue?
Which issue? The path issue? If you give a src attribute an improper
source file, then IE will get a "404 Page not Found" file and insert it
in the src since it can't find the file it was hunting. And since the
first few characters of that file are <html, it is a syntax error in the
script block.
And yes, you are rihgt! I still get the runtime error!!


Runtime Error or Syntax Error?
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
1
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.