1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

一个JS

本帖由 OUYANG2007-03-28 发布。版面名称:前端开发

  1. OUYANG

    OUYANG New Member

    注册:
    2005-09-06
    帖子:
    3,025
    赞:
    5
    HTML:
    <SCRIPT language=javascript>
    <!--
    function initArray()
    {
    for(i=0;i<initArray.arguments.length;i++)
    this[i]=initArray.arguments[i];
    }
    var isnMonths=new initArray("01月","02月","03月","04月","05月","06月","07月","08月","09月","10月","11月","12月");
    var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
    today=new Date();
    hrs=today.getHours();
    min=today.getMinutes();
    sec=today.getSeconds();
    clckh=""+((hrs>12)?hrs-12:hrs);
    clckm=((min<10)?"0":"")+min;clcks=((sec<10)?"0":"")+sec;
    clck=(hrs>=12)?"下午":"上午";
    var stnr="";
    var ns="0123456789";
    var a="";
    function getFullYear(d)
    {
    yr=d.getYear();if(yr<1000)
    yr+=1900;return yr;} 
    //下面各行分别是一种风格,把不需要的删掉即可
    document.write(""+getFullYear(today)+"年"+isnMonths[today.getMonth()]+""+today.getDate()+"日 "+isnDays[today.getDay()]+"");
    //-->
    </SCRIPT>
    <SPAN id=liveclock 9px? height: 9px; style?="width:"></SPAN>
    <SCRIPT language=javascript>
    function shijian()
    {
    var Digital=new Date()
    var hours=Digital.getHours()
    var minutes=Digital.getMinutes()
    var seconds=Digital.getSeconds()
    
    if(minutes<=9)
    minutes="0"+minutes
    if(seconds<=9)
    seconds="0"+seconds
    myclock=""+hours+":"+minutes+":"+seconds+""
    if(document.layers){document.layers.liveclock.document.write(myclock)
    document.layers.liveclock.document.close()
    }else if(document.all)
    liveclock.innerHTML=myclock
    setTimeout("shijian()",1000)
    }
    shijian();
    //-->
    </SCRIPT>
    </DIV>
    <DIV class=h_t1_r>
    <SCRIPT language=LiveScript>
    now = new Date(),hour = now.getHours()
    if(hour < 6){document.write("明天不用上班了吗?熬夜对身体不好哦!")}
    else if (hour < 8){document.write("全新的一天!应该早点锻炼哦!")}
    else if (hour < 12){document.write("早上好!愿你有顺畅的一天!")}
    else if (hour < 14){document.write("吃过饭了吗?睡个午觉吧!")}
    else if (hour < 18){document.write("下午好!望望窗外绿色的植物,别累坏眼睛哦!")}
    else if (hour < 22){document.write("晚上好!一天的工作忙完了,在网上散散心吧!")}
    else if (hour < 24){document.write("夜深了! 要注意身体呀! 祝你做个好梦!")}
    // -->
    </SCRIPT>