<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The important thing in life is to have a great aim , and the determination

    常用鏈接

    統計

    IT技術鏈接

    保險相關

    友情鏈接

    基金知識

    生活相關

    最新評論

    簡單的JS日期表示

    代碼如下:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>

    <BODY>
    <script language="javascript">
    todayDate = new Date();
    date = todayDate.getDate();
    month= todayDate.getMonth() +1;
    year= todayDate.getYear();
    document.write("? 今天是")
    document.write("<br>")
    if(navigator.appName == "Netscape")
    {
    ?document.write(1900+year);
    ?document.write("年");
    ?document.write(month);
    ?document.write("月");
    ?document.write(date);
    ?document.write("日");
    ?document.write("<br>")
    }
    if(navigator.appVersion.indexOf("MSIE") != -1)
    {
    document.write(year);
    document.write("年");
    document.write(month);
    document.write("月");
    document.write(date);
    document.write("日");
    document.write("<br>")
    }
    if (todayDate.getDay() == 5) document.write("? 星期五")
    if (todayDate.getDay() == 6) document.write("? 星期六")
    if (todayDate.getDay() == 0) document.write("? 星期日")
    if (todayDate.getDay() == 1) document.write("? 星期一")
    if (todayDate.getDay() == 2) document.write("? 星期二")
    if (todayDate.getDay() == 3) document.write("? 星期三")
    if (todayDate.getDay() == 4) document.write("? 星期四")

    </script>
    </BODY>
    </HTML>

    源代碼解釋:

    todayDate = new Date();
    當定義一個新的對象時,通常使用“new”操作符。在這里,就是創建了日期對象。
    date = todayDate.getDate();

    getDate()是Date對象的一種方法,其功能是獲得當前的日期。
    month= todayDate.getMonth() + 1 ;
    ;
    getMonth()是Date對象的一種方法,其功能是獲得當前的日期,由于月份是從0開始的,所以這里要“+1”。
    year= todayDate.getYear() getYear()是Date對象的一種方法,其功能是獲得當前的年份。
    document.write("今天是") document.write("<br>") 輸出“今天是”
    if(navigator.appName == "Netscape") { document.write(1900+year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日");
    document.write("<br> ") }
    如果瀏覽器是Netscape,輸出今天是“year”+“年”+“month”+“月”+“date”+“日”,其中年要加1900。
    if(navigator.appVersion.indexOf("MSIE") != -1) { document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日");
    document.write("<br> ") }
    如果瀏覽器是IE,直接輸出今天是“year”+“年”+“month”+“月”+“date”+“日”。
    document.write("") ; 在“日期”與“星期”之間輸入一個空格。
    if (todayDate.getDay() == 5) document.write("星期五");
    if (todayDate.getDay() == 6) document.write("星期六");
    if (todayDate.getDay() == 0) document.write("星期日");
    if (todayDate.getDay() == 1) document.write("星期一");
    if (todayDate.getDay() == 2) document.write("星期二");
    if (todayDate.getDay() == 3) document.write("星期三");
    if (todayDate.getDay() == 4) document.write("星期四")
    getDay()是Date對象的一種方法,其功能是獲得當前是星期幾。document.write輸出今天是“星期幾”。

    posted on 2007-03-23 11:18 鴻雁 閱讀(423) 評論(0)  編輯  收藏

    主站蜘蛛池模板: 日产国产精品亚洲系列| 亚洲综合久久综合激情久久| 亚洲无码在线播放 | 亚洲中文字幕久久精品无码VA| 中文字幕无线码免费人妻| 久久久久国色AV免费看图片| 国产亚洲美女精品久久久久狼| 美女免费精品高清毛片在线视| 91精品成人免费国产片| 国产精品久久久亚洲| 国产精品内射视频免费| 国产偷国产偷亚洲清高动态图| 亚洲精品国产日韩无码AV永久免费网| 亚洲成年人在线观看| 无码人妻一区二区三区免费看| 中文字幕久久亚洲一区| 嘿嘿嘿视频免费网站在线观看| 亚洲一区二区三区免费观看| 久久国产免费福利永久| 特级毛片免费播放| 亚洲字幕在线观看| 久久WWW免费人成人片| 一级女人18片毛片免费视频| 亚洲精品成人久久久| xvideos永久免费入口| 亚洲一区二区三区免费观看 | 爱情岛亚洲论坛在线观看| 日本高清免费不卡视频| 国产精品亚洲lv粉色| 亚洲视频一区在线观看| 全免费A级毛片免费看网站| 色天使色婷婷在线影院亚洲| 亚洲日本国产精华液| 亚洲第一极品精品无码久久| 在线a亚洲v天堂网2018| 成人免费777777| 99在线视频免费观看| 亚洲国产成人久久99精品| 日韩免费电影在线观看| 免费精品国偷自产在线在线| 免费国产高清毛不卡片基地 |