• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Accessibility

      Build web projects usable for all

    • Web Technology

      Web technology reference for developers

  • Learn
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Plus
    • Overview

      A customized MDN experience

    • AI Help

      Get real-time assistance and support

    • Updates

      All browser compatibility updates at a glance

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Curriculum New
  • Blog
    • Playground

      Write, test and share your code

    • HTTP Observatory

      Scan a website for free

    • AI Help

      Get real-time assistance and support

  • Log in
  • Sign up for free
  1. 面向开发者的 Web 技术
  2. Web API
  3. DOMException
  4. DOMException.code
    • English (US)
    • Deutsch
    • 日本語

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

在本文中

  • 语法
  • 规范
  • 浏览器兼容性
  1. 文档对象模型(DOM)
  2. DOMException
  3. 构造函数
    1. DOMException()
  4. 实例属性
    1. code 已弃用
    2. message
    3. name
  5. DOM 的相关页面
    1. AbortController
    2. AbortSignal
    3. AbstractRange
    4. Attr
    5. CDATASection
    6. CharacterData
    7. Comment
    8. CustomEvent
    9. DOMError 已弃用
    10. DOMImplementation
    11. DOMParser
    12. DOMPoint
    13. DOMPointReadOnly
    14. DOMRect
    15. DOMTokenList
    16. Document
    17. DocumentFragment
    18. DocumentType
    19. Element
    20. Event
    21. EventTarget
    22. HTMLCollection
    23. MutationObserver
    24. MutationRecord
    25. NamedNodeMap
    26. Node
    27. NodeIterator
    28. NodeList
    29. ProcessingInstruction
    30. Range
    31. StaticRange
    32. Text
    33. TextDecoder
    34. TextEncoder
    35. TimeRanges
    36. TreeWalker
    37. XMLDocument

在本文中

  • 语法
  • 规范
  • 浏览器兼容性

DOMException.code

DOMException 接口中的 code 是一个只读属性,他返回了一个包含了 错误常量 的简短数字,或者在没有匹配到时返回 0 。这个字段产生于历史原因,在新的 DOM 异常中已停止使用,改为在 DOMException.name 属性中推送此信息。

语法

var domExceptionCode = domExceptionInstance.code;

值

一个数字

规范

Specification
Web IDL
# dom-domexception-code

浏览器兼容性

Help improve MDN

Learn how to contribute.

This page was last modified on 2024年12月13日 by MDN contributors.

View this page on GitHub • Report a problem with this content
MDN logo

Your blueprint for a better internet.

  • MDN on Bluesky
  • MDN on Mastodon
  • MDN on X (formerly Twitter)
  • MDN on GitHub
  • MDN Blog RSS Feed

MDN

  • About
  • Blog
  • Careers
  • Advertise with us

Support

  • Product help
  • Report an issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Hacks Blog
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2025 by individual mozilla.org contributors. Content available under a Creative Commons license.