emu in blogjava

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            171 隨筆 :: 103 文章 :: 1052 評論 :: 2 Trackbacks
          測試代碼:
          try{abc();}catch(e){
              
          for(var i in e){
                  document.write(
          "<p><b>"+i+"</b>:"+e[i]+"</p>");
              }
          }

          在IE下:

          name:TypeError

          message:缺少對象

          number:-2146823281

          description:缺少對象


          在FireFox下

          message:abc is not defined

          fileName:file:///C:/test.html

          lineNumber:14

          stack:@file:///C:/test.html:14

          name:ReferenceError


          在safari下:

          message:Can't find variable: abc

          line:14

          sourceId:4

          sourceURL:file:///C:/test.html

          name:ReferenceError


          最爛的是opera:
          message:Statement on line 4: Reference to undefined variable: abc Backtrace: Line 4 of inline#1 script in file://localhost/C:/test.html abc();

          opera#sourceloc:4

          雖然message是所有瀏覽器都支持,但是所有瀏覽器的message都不同,而且不同語言版本的操作系統和瀏覽器也有不同。

          因此要做跨瀏覽器的異常區分處理,emu認為最好是用name來區分異常類型,這樣就只有瀏覽器的不同而沒有語言版本的不同了。opera做的這么爛,以至于只能從message入手,還是最后再考慮做對它的支持吧。

          posted on 2007-07-25 14:31 emu 閱讀(2002) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 扬州市| 邵阳县| 宜良县| 阳江市| 马公市| 岳阳市| 静海县| 德化县| 罗山县| 嘉鱼县| 大姚县| 南部县| 通许县| 太和县| 苏尼特左旗| 阳谷县| 饶河县| 隆昌县| 漯河市| 孟村| 邓州市| 新宾| 南靖县| 宜章县| 府谷县| 津南区| 青田县| 林芝县| 特克斯县| 莱阳市| 平邑县| 蒙自县| 富平县| 若羌县| 天气| 永和县| 教育| 汉中市| 石屏县| 长沙市| 依安县|