473,563 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DisplayTimeInSt atusLine() - 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\JavaScr ipt\DisplayTime InStatusLine.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 DisplayTimeInSt atusLine(){
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(Dis playTimeInStatu sLine(), 60000);
}
</SCRIPT>
</HEAD>
</HTML>
---------- end of snip 1 --------

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

<body bgcolor="#00000 0" style="text-align: left"
onLoad="Display TimeInStatusLin e();">
......
----- 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 1227
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\JavaScri pt\DisplayTimeI nStatusLine.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 DisplayTimeInSt atusLine(){
It is a convention that only constructors start with a capital letter,
so make that:

function displayTimeInSt atusLine(){

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(Dis playTimeInStatu sLine(), 60000);


The first argument to setInterval should be a string. Your function
will execute displayTimeInSt atusLine() 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 DisplayTimeInSt atusLine():

setInterval('di splayTimeInStat usLine()', 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.c om/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.htm l ---

<%@ Language=JavaSc ript %>
<html>
<head>
<!-- saved from url=(0014)about :internet -->
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR " content="Micros oft FrontPage 5.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Jamiil 's Home Page</title>
<SCRIPT SRC=".\JavaScri pt\DisplayTimeI nSatatusBar.js" ></SCRIPT>
</head>

--- Snip in .\dev\JavaScrip t\DisplayTimeIn StatusBar.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 displayTimeInSt atusBar(){
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('di splayTimeInStat usBar()', 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.htm l ---

<%@ Language=JavaSc ript %>
<html>
<head>
<!-- saved from url=(0014)about :internet -->
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR " content="Micros oft FrontPage 5.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Jamiil 's Home Page</title>
<SCRIPT SRC=".\JavaScri pt\DisplayTimeI nSatatusBar.js" ></SCRIPT>
</head>

--- Snip in .\dev\JavaScrip t\DisplayTimeIn StatusBar.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\JavaScrip t\... 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.javas cript 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.ht ml
c:\dev\sound\so und_files.wav
c:\dev\JavaScri pt\DisplayTimeI nStatusBar.js
......
When including the *.js, I used relative address
<html>
<head>
....
<SCRIPT SRC="JavaScript \DisplayTimeInS atatusBar.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.c om, 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.ht ml
c:\dev\sound\so und_files.wav
c:\dev\JavaScri pt\DisplayTimeI nStatusBar.js
......
When including the *.js, I used relative address
<html>
<head>
....
<SCRIPT SRC="JavaScript \DisplayTimeInS atatusBar.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.javas cript 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
6504
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 Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to...
6
4316
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 result in any way. Who can help me, I thank you very very much. list.cpp(main program)...
3
3334
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 numarray, help gives unhelpful responses:
7
5351
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 from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not...
5
3253
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 using "F1" help within the VB IDE. Is this expectation achievable In trying to test my help file in the IDE, I have a solution with 2 projects:...
8
3210
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 including search the internet for help, but the help is worthless. Any ideas?
10
3343
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 the worst I ever seen. I almost cannot find anything I need, including things I
1
6117
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 default property of object Label. Click for more:...
0
2862
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 calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar, FILE EDIT VIEW INSERT ... HELP. I am able to see the menu bar, but in...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.