一點一滴,編程人生

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            69 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks
          今天查看某網(wǎng)站時發(fā)現(xiàn)其日期顯示的不對,顯示為:109年12月28日 星期一(我用的是chrome),后來在IE中測試,沒有問題,顯示為:2009年12月28日,最后在FF中測試也是有問題的。我查看其源代碼,如下:
           1 <script language="JavaScript" type="text/javascript">
           2         var curdate=new Date();
           3         day=curdate.getDay();
           4         mm=curdate.getMonth()+1;
           5         date=curdate.getDate();
           6         year=curdate.getYear();
           7         var theday;
           8         switch(day)
           9         {
          10          case 1: theday=""break;
          11          case 2: theday=""break;
          12          case 3: theday=""break;
          13          case 4: theday=""break;
          14          case 5: theday=""break;
          15          case 6: theday=""break;
          16          case 0: theday=""break;
          17         }
          18         alert(year);
          19         document.write(year+""+mm+""+date+""+"&nbsp;"+"星期"+theday);
          20 </script>

          看來是第6行的getYear函數(shù)出現(xiàn)了問題,我便用getFullYear函數(shù)替換它,問題解決了。看來IE與其它瀏覽器的getYear函數(shù)實現(xiàn)是不同的,以后做開發(fā)時要注意這個特殊問題。
          posted on 2009-12-28 11:49 writegull 閱讀(403) 評論(0)  編輯  收藏 所屬分類: javascript
          主站蜘蛛池模板: 皮山县| 平顺县| 黄龙县| 隆林| 德格县| 衡山县| 莲花县| 仁怀市| 庄浪县| 长岭县| 望江县| 彝良县| 兴和县| 东平县| 赣州市| 靖安县| 剑河县| 白玉县| 濮阳市| 浮梁县| 安泽县| 墨玉县| 淮滨县| 巴林左旗| 卓资县| 麟游县| 普定县| 庆安县| 昌黎县| 湟中县| 淮阳县| 沁水县| 岚皋县| 东阿县| 石嘴山市| 三门县| 左贡县| 通榆县| 疏附县| 嘉义市| 漳浦县|