JS實現瀏覽器狀態列顯示時間的方法,js實現瀏覽器狀態列

來源:互聯網
上載者:User

JS實現瀏覽器狀態列顯示時間的方法,js實現瀏覽器狀態列

本文執行個體講述了JS實現瀏覽器狀態列顯示時間的方法。分享給大家供大家參考,具體如下:

以前做個人首頁的時候,總喜歡把自己的網頁搞的很個性,在網上做跑馬燈文字,在狀態列顯示問候語,或者在狀態列添加時間顯示,本代碼就是實現了狀態列顯示目前時間的物資,Firefox沒測度,IE下效果完美。

運行效果如下:

線上示範地址如下:

http://demo.jb51.net/js/2015/js-status-bar-show-time-demo/

具體代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE>狀態列時間顯示</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 < 10) ? ":0" : ":") + seconds  timeValue += (hours >= 12) ? " 下午" : " 上午"  window.status = timeValue;  timerID = setTimeout("showtime()",1000);  timerRunning = true;}function startclock () {  stopclock();  showtime();}</script><body bgcolor="#336699" topmargin="0" leftmargin="0" onLoad="startclock()">請看左下角!狀態列有時間顯示!</BODY></HTML>

希望本文所述對大家JavaScript程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.