The DOMException exception represents an abnormal event happening when a method or a property is used.
Attributes
-
DOMException.codeRead only -
Returns a
shortthat contains one of the error code constants, or0if none match. This field is used for historical reasons, new kind of DOM exceptions don't use anymore: they put this info in theDOMException.nameattribute. -
DOMException.nameRead only -
Returns a
DOMStringthat contains one of the string associated with an error constant.
Error Constants
-
IndexSizeError -
The index is not in the allowed range. For example, this can be thrown by
Rangeobject. (Legacy code value:1and legacy constant name:INDEX_SIZE_ERR) -
HierarchyRequestError -
The node tree hierarchy is not correct. (Legacy code value:
3and legacy constant name:HIERARCHY_REQUEST_ERR) -
WrongDocumentError -
The object is in the wrong
Document. (Legacy code value:4and legacy constant name:WRONG_DOCUMENT_ERR) -
InvalidCharacterError -
The string contains invalid characters. (Legacy code value:
5and legacy constant name:INVALID_CHARACTER_ERR) -
NoModificationAllowedError -
The object can not be modified. (Legacy code value:
7and legacy constant name:NO_MODIFICATION_ALLOWED_ERR) -
NotFoundError -
The object can not be found here. (Legacy code value:
8and legacy constant name:NOT_FOUND_ERR) -
NotSupportedError -
The operation is not supported. (Legacy code value:
9and legacy constant name:NOT_SUPPORTED_ERR) -
InvalidStateError -
The object is in an invalid state. (Legacy code value:
11and legacy constant name:INVALID_STATE_ERR) -
SyntaxError -
The string did not match the expected pattern. (Legacy code value:
12and legacy constant name:SYNTAX_ERR) -
InvalidModificationError -
The object can not be modified in this way. (Legacy code value:
13and legacy constant name:INVALID_MODIFICATION_ERR) -
NamespaceError -
The operation is not allowed by Namespaces in XML. (Legacy code value:
14and legacy constant name:NAMESPACE_ERR) -
InvalidAccessError -
The object does not support the operation or argument. (Legacy code value:
15and legacy constant name:INVALID_ACCESS_ERR) -
TypeMismatchError -
The type of the object does not match the expected type. (Legacy code value:
17and legacy constant name:TYPE_MISMATCH_ERR) This value is deprecated, the JavaScriptTypeErrorexception is now raised instead of aDOMExceptionwith this value. -
SecurityError -
The operation is insecure. (Legacy code value:
18and legacy constant name:SECURITY_ERR) -
NetworkError -
A network error occurred. (Legacy code value:
19and legacy constant name:NETWORK_ERR) -
AbortError -
The operation was aborted. (Legacy code value:
20and legacy constant name:ABORT_ERR) -
URLMismatchError -
The given URL does not match another URL. (Legacy code value:
21and legacy constant name:URL_MISMATCH_ERR) -
QuotaExceededError -
The quota has been exceeded. (Legacy code value:
22and legacy constant name:QUOTA_EXCEEDED_ERR) -
TimeoutError -
The operation timed out. (Legacy code value:
23and legacy constant name:TIMEOUT_ERR) -
InvalidNodeTypeError -
The node is incorrect or has an incorrect ancestor for this operation. (Legacy code value:
24and legacy constant name:INVALID_NODE_TYPE_ERR) -
DataCloneError -
The object can not be cloned. (Legacy code value:
25and legacy constant name:DATA_CLONE_ERR) -
EncodingError - The encoding operation, being an encoding or a decoding one, failed (No legacy code value and constant name).
-
NotReadableError - The input/output read operation failed (No legacy code value and constant name).
Specifications
| Specification | Status | Comment |
|---|---|---|
| DOM The definition of 'DOMException' in that specification. |
Living Standard | Since the latest snapshot, DOM4, and the NotReadableErrorvalue have been added. |
| DOM4 The definition of 'DOMException' in that specification. |
Working Draft | Added SECURITY_ERR, NETWORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, QUOTA_EXCEEDED_ERR, TIMEOUT_ERR, INVALID_NODE_TYPE_ERR, and DATA_CLONE_ERR.The property code has been deprecated for exception values.The EncodingError value added. |
| Document Object Model (DOM) Level 3 Core Specification The definition of 'DOMException' in that specification. |
Recommendation | Added of VALIDATION_ERR and TYPE_MISMATCH_ERR. |
| Document Object Model (DOM) Level 2 Core Specification The definition of 'DOMException' in that specification. |
Recommendation | Added of INVALID_STATE_ERR, SYNTAX_ERR, INVALID_MODIFICATION_ERR, NAMESPACE_ERR, and INVALID_ACCESS_ERR. |
| Document Object Model (DOM) Level 1 Specification The definition of 'DOMException' in that specification. |
Recommendation | Initial definition. |
Browser compatibility
Help improve compatibility tables by filling out this 11 question survey.
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | ? | 1.0 (1.7 or earlier) | ? | ? | ? |
| DOM Level 4 support | ? | 13.0 (13.0) | ? | ? | ? |
DATA_CLONE_ERR constant |
? | 5.0 (5.0) | ? | ? | ? |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | 1.0 (1.0) | ? | ? | ? |
| DOM Level 4 support | ? | 13.0 (13.0) | ? | ? | ? |
DATA_CLONE_ERR constant |
? | 5.0 (5.0) | ? | ? | ? |
See also
Document Tags and Contributors
Tags:
Contributors to this page: DomenicDenicola, Sheppy, fscholz, CHaoSlayeR, devinrhode2, Brettz9, kscarfone, teoli, user01
Last updated by:
teoli,