Documentation Center

DOMException

This event can be used to catch errors relating to DOM Operations.

Description

See DOM Level 3 Core- DOMException for more information about the DOMException.

Example

try
{
  var title = doc.createElement("title");
  doc.getDocumentElement().appendChild(title);
}
catch (/* DOMException */ e)
{
  switch (e.code)
  {
    case 16:
      // VALIDATION_ERR
      alert("Inserting a title is not allowed");
      break;
    
    default:
      alert(e);
      break;
  }
}