简体   繁体   English

未定义Javascript Dump()

[英]Javascripts Dump() is not defined

Was just looking around MDN about window.location and the example that they had given was: 只是在MDN中查看有关window.location的信息,他们给出的示例是:

 dump(document.location); // Prints a string like // "http://www.example.com/juicybits.html" to the console 

So I open up my console and type in dump(document.location) and all I keep getting is dump is not defined . 所以我打开控制台并输入dump(document.location)而我一直得到的只是dump is not defined I even tried window.dump(document.location) . 我什至尝试了window.dump(document.location)

I then proceeded to look at the API for dump on MDN here but it seemed like I was using it properly. 然后,我继续在此处查看要在MDN上转储的API,但似乎我使用得当。

I also tried it in Firefox - but still kept getting undefined So I then tried enabling it with window.dump.enabled - but that didn't do anything for me either. 我也在Firefox中进行了尝试-但仍处于undefined因此我尝试通过window.dump.enabled启用它-但这对我也没有任何作用。

Here is a screen cap of my Mozilla console: 这是我的Mozilla控制台的屏幕截图:

在此处输入图片说明

What could I be missing here? 我在这里可能想念什么?

这是特定于Firefox(mozilla)的功能。

It says right in the docs you link to (emphasis mine): 它说在您链接到的文档中(强调我):

A common use of dump() is to debug JavaScript. dump()常见用法是调试JavaScript。 The message passed to dump() is sent to the System Console (Native Console) if the Firefox proces was started withe the -console option . 如果使用-console选项启动了Firefox,则传递给dump()的消息将发送到系统控制台(本机控制台) If the -console option was not specified then the output goes to stderr. 如果未指定-console选项,则输出将转到stderr。 Output from dump() is not sent to the Browser Console. dump()输出不会发送到浏览器控制台。 Output can be sent to the Browser Console using console.log() . 可以使用console.log()将输出发送到浏览器控制台。 Privileged code can also use Components.utils.reportError and nsIConsoleService to log messages to the Error Console/Browser Console. 特权代码还可以使用Components.utils.reportErrornsIConsoleService将消息记录到错误控制台/浏览器控制台。

You can't enable it and have it do something other than what it says it'll do, you need to look in the correct place for output, which isn't the browser console, rather where the docs say. 您无法启用它并使它执行其将要执行的操作之外的其他功能,您需要在正确的位置进行输出,这不是浏览器控制台,而是文档所说的位置。

You can call it from the console, and are . 可以从控制台调用它,并且 It returns undefined , just like console.log . 它返回undefined ,就像console.log一样。

Type in dump : 输入dump

[16:40:57.545] dump
[16:40:57.547] [object Function]

It's defined. 已定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM