开发者

Javascript : Manipulating the status bar to display the date?

开发者 https://www.devze.com 2023-03-18 18:09 出处:网络
I\'m trying to write a script to disp开发者_运维问答lay the current time on a page every minute on the status bar. However nothing shows up on the bar and I have no idea what is wrong.

I'm trying to write a script to disp开发者_运维问答lay the current time on a page every minute on the status bar. However nothing shows up on the bar and I have no idea what is wrong.

        function display_time(){

            var d = new Date();
            var h = d.getHours(); // Extract hours
            var m = d.getMinutes(); // Extract minutes
            var ampm = (h >= 12)?"PM":"AM" // Convert to 12 hr format


            if (h > 12) h -= 12; // Next 4 lines; convert time to 12hr format
            if (h==0) h = 12; 
            if (m < 10) m = "0" + m;
            var t = h + ':' + m + ' ' + ampm;
            defaultStatus = t;

            // Repeat function every minute
            setTimeout('display_time()', 60000);                         
        }

And Finally I call it as the page loads with <body onload= 'display_time();'>

The time however doesn't show in the status bar of any browser. Any thoughts?


Use window.status instead of defaultStatus. But please be aware that you can't change the status bar in some browsers.

0

精彩评论

暂无评论...
验证码 换一张
取 消