JS implementation of browser status bar display time method _javascript skills

Source: Internet
Author: User
Tags add time

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.