pile0nades wrote:Code: Select all
var title = document.title;
function doTheClock() {
window.setTimeout( "doTheClock()", 1000 );
t = new Date();
var timestr = " - " + t.toString().substring(0, t.toString().indexOf("(") - 1);
document.title = title + timestr;
}
doTheClock();
How's this?
pile0nades, It works but it duplicates the time in the titlebar for every tab I have open whilst using session manager
/* Zoolcar9's below */
Zoolcar9 wrote:Code: Select all
function doTheClock() {
var title = content.document.title;
window.setTimeout( "doTheClock()", 1000 );
var t = new Date();
var timestr = " - " + t.toString().substring(0, t.toString().indexOf("GMT") - 1);
document.title = title + timestr;
}
doTheClock();
This code works. Now,lol... Any way to lose the seconds and make it twelve hour with AM/PM?
Thank's to both of you for the help!
Edit: OK, nevermind about the seconds, that really doesn't bother me. I've got this to work mostly the way I want it with one exception, with my latest code I don't know how to add the title back in with what I've come with. In playing around with this, I see that I can do away with the extension "Title Bar Tweaks". Anyway, what I would like to do now is add the browser/page title into my latest code if possible Code: Select all
function clock() {
var timerID = null;
var timerRunning = false;
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds <10>= 12) ? " PM" : " AM"
timerID = setTimeout("clock()",100);
timerRunning = true;
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;}
today = "Greg's Firefox 1.5" + " - " + days[dateNow.getDay()] + " - " +
months[dateNow.getMonth()] + " " +
date + ", " +
(y2k(dateNow.getYear())) + " - " + timeValue;
if(document.all || document.getElementById){
document.title = today.toString();
}else{
self.status = today.toString();
}
}
clock();
Edit 2: Nevermind, I figured it out. Thanks!