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 阅读(1990) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: