Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems on displaying Live time on status bar 1

Status
Not open for further replies.

OOP

Programmer
Feb 5, 2001
94
SG
Hi all,

Start to pick up javascript lately and trying out a simple script to update my time on the windows status bar. My code is as follows:

Code:
//Inside the Header tag

function displaytime(){
var currenttime = '<?php print date("F d, Y H:i:s", time())?>' 
window.status =currenttime
}

window.onload=function(){
setInterval("displaytime()", 1000)
}
If working correctly, the code should show the user the LIVE time on the status bar...but its not.(it only display once upon loading and that's it :( )

Any help is greatly appreciated. Thank you.
 
Yes - because PHP evaluates server-side, the date and time will never change unless you refresh the page.

Either use JavaScript to get the time / date in the loop (client side), or use the settInterval to refresh the page (constantly forcing the server-side value to update).

Hope this helps,
Dan




[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan,
Thanks for your helpful reply^^
Think i'll give up the idea on 'Live time'....just show the user the time once he / she loads the page is enough..

By the way, do you (or anyone viewing this post ) has any idea of does Netscape browser supports this window.status javascript?

Any help will be appreciated. Thanks.
 
All versions of Netscape from 4.x upwards support it... however, I believe from v6.x upwards, the user can choose whether to allow it to be changed or not - and I think the default may be "no".

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top