JavaScript在浏览器标题栏上显示当前日期和时间的方法

前端之家收集整理的这篇文章主要介绍了JavaScript在浏览器标题栏上显示当前日期和时间的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了JavaScript在浏览器标题栏上显示当前日期和时间的方法分享给大家供大家参考。具体如下:

将这段脚本放到head区即可:

12) ? hours -12 :hours) timeValue = ((timeValue <10)? "0":"") + timeValue timeValue += ((minutes < 10) ? ":0" : ":") + minutes timeValue += ((seconds < 10) ? ":0" : ":") + seconds timeValue += (hours >= 12) ? " PM" : " AM" timerID = setTimeout("resetIt()",100); timerRunning = true; // getDate var dateNow = new Date(); var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); var date = ((dateNow.getDate()<10) ? "0" : "")+ dateNow.getDate(); function y2k(number){return (number < 1000) ? number + 1900 : number;} // compileIt today = timeValue + " " + days[dateNow.getDay()] + " " + months[dateNow.getMonth()] + "," + date + " " + (y2k(dateNow.getYear())); if(document.all || document.getElementById){ // Browser Check document.title = today.toString(); }else{ self.status = today.toString(); // Default to status. } } resetIt(); //-->

希望本文所述对大家的javascript程序设计有所帮助。

原文链接:https://www.f2er.com/js/55184.html

猜你在找的JavaScript相关文章