非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

Window.dump() prints messages to the (native) console.

句法

window.dump(message);
dump(message);
					

参数

  • message is the string message to log.

注意事项

A common use of dump() is to debug JavaScript. The message passed to dump() is sent to the System Console (Native Console) if the Firefox process was started with the -console option. If the -console option was not specified then the output goes to stderr. Output from dump() is not sent to the Browser Console . Output can be sent to the Browser Console 使用 console.log() . Privileged code can also use Components.utils.reportError and nsIConsoleService to log messages to the Error Console / Browser Console .

dump() is also available to XPCOM components implemented in JavaScript, even though window is not the global object in components. It is also explicitly made available in sandboxes . However, this use of dump is not affected by the preference mentioned below -- it will always be shown. It is therefore advisable to either check this preference yourself or use a debugging preference of your own to make sure you don't send lots of debugging content to a user's console when they might not be interested in it at all. Note that dump output from XPCOM components goes to stderr ,而 dump called elsewhere will output to stdout .

Gecko dump() is disabled by default – it doesn't do anything but doesn't raise an error either. To see the dump output you have to enable it by setting the preference browser.dom.window.dump.enabled to true . You can set the preference in about:config 或在 user.js file . Note: this preference is not listed in about:config by default, you may need to create it (right-click the content area -> New -> Boolean).

On Windows, you will need a console to actually see anything. If you don't have one already, closing the application and re-opening it with the command line parameter -console should create the console or use -attach-console to use the existing console. On other operating systems, it's enough to launch the application from a terminal.

To redirect the console output to a file, run firefox without the -console option and use the syntax to redirect stderr and stdout to a file, i.e.:

firefox > console.txt 2>&1
					

If you would like the console messages to appear in the console you used to launch the application, you can use the Gecko Console Redirector . Precompiled binaries are available in the zipped archive https://github.com/matthewkastor/Redirector/archive/master.zip under Redirector-master\Gecko\Console Redirector\bin\Release Copy all the dll's and the exe to wherever you want. Then run Console Redirector.exe /?

规范

This is not part of any specification

元数据

  • 最后修改:
  1. Window
  2. 特性
    1. applicationCache
    2. caches
    3. closed
    4. console
    5. controllers
    6. crossOriginIsolated
    7. crypto
    8. customElements
    9. defaultStatus
    10. devicePixelRatio
    11. dialogArguments
    12. 目录
    13. document
    14. event
    15. frameElement
    16. frames
    17. fullScreen
    18. history
    19. indexedDB
    20. innerHeight
    21. innerWidth
    22. isSecureContext
    23. isSecureContext
    24. length
    25. localStorage
    26. location
    27. locationbar
    28. menubar
    29. mozAnimationStartTime
    30. mozInnerScreenX
    31. mozInnerScreenY
    32. mozPaintCount
    33. 名称
    34. navigator
    35. onabort
    36. onafterprint
    37. onanimationcancel
    38. onanimationend
    39. onanimationiteration
    40. onappinstalled
    41. onauxclick
    42. onbeforeinstallprompt
    43. onbeforeprint
    44. onbeforeunload
    45. onblur
    46. oncancel
    47. oncanplay
    48. oncanplaythrough
    49. onchange
    50. onclick
    51. onclose
    52. oncontextmenu
    53. oncuechange
    54. ondblclick
    55. ondevicelight
    56. ondevicemotion
    57. ondeviceorientation
    58. ondeviceorientationabsolute
    59. ondeviceproximity
    60. ondragdrop
    61. ondurationchange
    62. onended
    63. onerror
    64. onfocus
    65. onformdata
    66. ongamepadconnected
    67. ongamepaddisconnected
    68. ongotpointercapture
    69. onhashchange
    70. oninput
    71. oninvalid
    72. onkeydown
    73. onkeypress
    74. onkeyup
    75. onlanguagechange
    76. onload
    77. onloadeddata
    78. onloadedmetadata
    79. onloadend
    80. onloadstart
    81. onlostpointercapture
    82. onmessage
    83. onmessageerror
    84. onmousedown
    85. onmouseenter
    86. onmouseleave
    87. onmousemove
    88. onmouseout
    89. onmouseover
    90. onmouseup
    91. onmozbeforepaint
    92. onpaint
    93. onpause
    94. onplay
    95. onpointercancel
    96. onpointerdown
    97. onpointerenter
    98. onpointerleave
    99. onpointermove
    100. onpointerout
    101. onpointerover
    102. onpointerup
    103. onpopstate
    104. onrejectionhandled
    105. onreset
    106. onresize
    107. onscroll
    108. onselect
    109. onselectionchange
    110. onselectstart
    111. onstorage
    112. onsubmit
    113. ontouchcancel
    114. ontouchstart
    115. ontransitioncancel
    116. ontransitionend
    117. onunhandledrejection
    118. onunload
    119. onuserproximity
    120. onvrdisplayactivate
    121. onvrdisplayblur
    122. onvrdisplayconnect
    123. onvrdisplaydeactivate
    124. onvrdisplaydisconnect
    125. onvrdisplayfocus
    126. onvrdisplaypointerrestricted
    127. onvrdisplaypointerunrestricted
    128. onvrdisplaypresentchange
    129. onwheel
    130. opener
    131. origin
    132. outerHeight
    133. outerWidth
    134. pageXOffset
    135. pageYOffset
    136. parent
    137. 性能
    138. personalbar
    139. pkcs11
    140. screen
    141. screenLeft
    142. screenTop
    143. screenX
    144. screenY
    145. scrollbars
    146. scrollMaxX
    147. scrollMaxY
    148. scrollX
    149. scrollY
    150. self
    151. sessionStorage
    152. sidebar
    153. speechSynthesis
    154. status
    155. statusbar
    156. toolbar
    157. top
    158. visualViewport
    159. window
  3. 方法
    1. alert()
    2. atob()
    3. back()
    4. blur()
    5. btoa()
    6. cancelAnimationFrame()
    7. cancelIdleCallback()
    8. captureEvents()
    9. clearImmediate()
    10. clearInterval()
    11. clearTimeout()
    12. close()
    13. confirm()
    14. convertPointFromNodeToPage()
    15. convertPointFromPageToNode
    16. createImageBitmap()
    17. dump()
    18. fetch()
    19. find()
    20. focus()
    21. forward()
    22. getAttention()
    23. getComputedStyle()
    24. getDefaultComputedStyle()
    25. getSelection()
    26. home()
    27. matchMedia()
    28. minimize()
    29. moveBy()
    30. moveTo()
    31. open()
    32. openDialog()
    33. postMessage()
    34. print()
    35. prompt()
    36. queueMicrotask()
    37. releaseEvents()
    38. requestAnimationFrame()
    39. requestFileSystem()
    40. requestIdleCallback()
    41. resizeBy()
    42. resizeTo()
    43. restore()
    44. routeEvent()
    45. scroll()
    46. scrollBy()
    47. scrollByLines()
    48. scrollByPages()
    49. scrollTo()
    50. setCursor()
    51. setImmediate()
    52. setInterval()
    53. setTimeout()
    54. showModalDialog()
    55. sizeToContent()
    56. stop()
    57. updateCommands()
  4. 事件
    1. event
    2. afterprint
    3. animationcancel
    4. animationend
    5. animationiteration
    6. beforeprint
    7. beforeunload
    8. blur
    9. copy
    10. cut
    11. DOMContentLoaded
    12. error
    13. focus
    14. hashchange
    15. languagechange
    16. load
    17. message
    18. messageerror
    19. offline
    20. online
    21. orientationchange
    22. pagehide
    23. pageshow
    24. paste
    25. popstate
    26. rejectionhandled
    27. storage
    28. transitioncancel
    29. unhandledrejection
    30. unload
    31. vrdisplayconnect
    32. vrdisplaydisconnect
    33. vrdisplaypresentchange