This article illustrates the method of JS to display the time of the browser status bar. Share to everyone for your reference, specific as follows:
When you used to be a personal homepage, always like to make their own web page to do a very personalized, on the Internet to do the text, in the status bar display greeting, or in the status bar to add time to show, this code is to achieve the status bar shows the current time of the material, Firefox did not measure, ie under the perfect effect.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-status-bar-show-time-demo/
The specific code is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> status bar time display </
title> </HEAD> <script language= "JavaScript" > var timerid = null;
var timerrunning = false;
function Stopclock () {if (timerrunning) cleartimeout (Timerid);
Timerrunning = false;
function Showtime () {var now = new Date ();
var hours = now.gethours ();
var minutes = now.getminutes (); var seconds = now.getseconds () var timevalue = "" + (Hours >12)? hours-12:hours) TimeValue + = (Minutes < 10)? ": 0": ":" + minutes TimeValue + + (seconds <)? ": 0": ":" + seconds TimeValue + + (hours >= 12)? "PM":
"Morning" window.status = TimeValue;
Timerid = settimeout ("Showtime ()", 1000);
Timerrunning = true;
function Startclock () {stopclock ();
Showtime (); } </script> <body bgcolor= "#336699" topmargin= "0" leftmargin= "0" onload= "Startclock ()" > Please look at the bottom left corner! The status bar has time to display! </BODY> </HTML>
I hope this article will help you with your JavaScript programming.