Javascript的Error对象在不同浏览器是不一样的.

简介:

IE比较搞,第一个参数是number,其他浏览器第一个参数是message。Firefox则除了支持message以外还加入了两个参数fileName和lineNumber。但是在其文档中注明了非标准(Non-standard)

IE的文档http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx

Firefox的文档https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error

 

各个浏览器的比较文档

http://help.dottoro.com/ljfhismo.php

http://www.aptana.com/reference/html/api/Error.html

Creating a new Error object:

Internet Explorer supports the following form:

var errorObj = new Error([number[, description]]);

number 
Optional. Integer that specifies the error code. Default is 0. Sets the error property of the Error object.

message 
Optional. String that specifies the message of the error. Default is an empty string. Sets the description and messageproperties of the Error object.

Firefox supports the following form:

var errorObj = new Error([message[, fileName[, lineNumber]]]);

message 
Optional. String that specifies the message of the error. Default is an empty string. Sets the description and messageproperties of the Error object.

fileName 
Optional. String that specifies the name of the file where the error occurs. Default is the file where the Error object is created. Sets the fileName property of the Error object.

lineNumber 
Optional. Integer that specifies the line number where the error occurs. Default is the line number, where the Errorobject is created. Sets the lineNumber property of the Error object.

Opera, Google Chrome and Safari support the following form:

var errorObj = new Error([message]);

message 
Optional. String that specifies the message of the error. Default is an empty string. Sets the description and messageproperties of the Error object.

    本文转自Jake Lin博客园博客,原文链接:http://www.cnblogs.com/procoder/archive/2012/12/06/2804848.html,如需转载请自行联系原作者



相关文章
|
3天前
|
JavaScript
浏览器插件crx文件--JS混淆与解密
浏览器插件crx文件--JS混淆与解密
10 0
|
14天前
|
JavaScript
JS 获取对象数据类型的键值对的键与值
JS 获取对象数据类型的键值对的键与值
|
24天前
|
JavaScript 前端开发
Math对象:JavaScript中的数学工具
Math对象:JavaScript中的数学工具
27 1
|
24天前
|
JavaScript 前端开发 UED
JS:如何获取浏览器窗口尺寸?
JS:如何获取浏览器窗口尺寸?
35 1
N..
|
1月前
|
存储 JavaScript 前端开发
JavaScript中的对象
JavaScript中的对象
N..
10 0
|
17天前
|
JavaScript 算法
原生JS完成“一对一、一对多”矩形DIV碰撞检测、碰撞检查,通过计算接触面积(重叠覆盖面积)大小来判断接触对象DOM
原生JS完成“一对一、一对多”矩形DIV碰撞检测、碰撞检查,通过计算接触面积(重叠覆盖面积)大小来判断接触对象DOM
|
2天前
|
存储 JavaScript 索引
js开发:请解释什么是ES6的Map和Set,以及它们与普通对象和数组的区别。
ES6引入了Map和Set数据结构。Map的键可以是任意类型且有序,与对象的字符串或符号键不同;Set存储唯一值,无重复。两者皆可迭代,支持for...of循环。Map有get、set、has、delete等方法,Set有add、delete、has方法。示例展示了Map和Set的基本操作。
16 3
|
3天前
|
JavaScript 前端开发 开发者
JavaScript中的错误处理:try-catch语句与错误对象
【4月更文挑战第22天】JavaScript中的错误处理通过try-catch语句和错误对象实现。try块包含可能抛出异常的代码,catch块捕获并处理错误,finally块则无论是否出错都会执行。错误对象提供关于错误的详细信息,如类型、消息和堆栈。常见的错误类型包括RangeError、ReferenceError等。最佳实践包括及时捕获错误、提供有用信息、不忽略错误、利用堆栈信息和避免在finally块中抛错。
|
7天前
|
JavaScript 前端开发
JavaScript如何获得浏览器的宽高
JavaScript如何获得浏览器的宽高
|
9天前
|
JavaScript
【Js】检查Date对象是否为Invalid Date
【Js】检查Date对象是否为Invalid Date
13 0