如何在 Firebug 中编辑 JavaScript?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3203779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:39:43  来源:igfitidea点击:

How to edit JavaScript in Firebug?

javascriptfirebugedit

提问by TCM

I am only able to view the JavaScript files of the website via the Scriptpanel. How can I edit it? I tried everything like double clicking the line that i want to edit etc., but it doesn't let me edit it.

我只能通过脚本面板查看网站的 JavaScript 文件。我怎样才能编辑它?我尝试了所有方法,例如双击要编辑的行等,但它不允许我编辑它。

If I move to the HTMLtab, I am able to edit the HTML by clicking on the Editbutton, but I am not able to edit the JavaScript.

如果我移动到HTML选项卡,我可以通过单击编辑按钮来编辑 HTML ,但我无法编辑 JavaScript。

采纳答案by Matthew Abbott

alt text
(source: fidelitydesign.net)

替代文字
(来源:fidelitydesign.net

You can use the Firebug Console tab to write Javascript. I use this quite a lot of rapid prototyping of code before I integrate it into my projects. When you use the Console, javascript is executed in the context of the current page. Therefore, and scripts that are currently defined for that page, can potentionally be redefind. E.g., in the Console window, I could do this:

您可以使用 Firebug 控制台选项卡编写 Javascript。在将其集成到我的项目中之前,我使用了大量的代码快速原型设计。当您使用控制台时,javascript 在当前页面的上下文中执行。因此,当前为该页面定义的脚本可能会被重新定义。例如,在控制台窗口中,我可以这样做:

$ = function() { alert("Whoops"); }

...and that would redefine the $function used by JQuery.

...这将重新定义$JQuery 使用的函数。

回答by Pavle Lekic

As far as I know only Chrome's dev tools support editing JavaScript inside their Sourcestab (not just via the command line). And you can add an extension like Tincror DevTools Autosaveand Chrome will save the changes to your JavaScript files on the disk. So it is pretty much a complete IDE for JavaScript.

据我所知,只有 Chrome 的开发工具支持在其Sources选项卡中编辑 JavaScript (不仅仅是通过命令行)。您可以添加一个扩展程序,如TincrDevTools Autosave,Chrome 会将更改保存到磁盘上的 JavaScript 文件中。所以它几乎是一个完整的 JavaScript IDE。

Otherwise if you are using Firebug, you would have to test your code in the Command Editor, then open your text editor and open that file you were looking in Firebug and then add those changes inside your text editor and save.

否则,如果您使用 Firebug,则必须在Command Editor 中测试您的代码,然后打开文本编辑器并打开您在 Firebug 中查找的文件,然后在文本编辑器中添加这些更改并保存。

I hope that one day they will enable JavaScript to be editable inside the Scriptpanelof Firebug.

我希望有一天他们能让 JavaScript 在Firebug的Script面板中进行编辑。

回答by Max Kielland

There is a "Scratchpad" built into the Mozilla framework. This can be reached from within Firefox.

Mozilla 框架中内置了一个“Scratchpad”。这可以从 Firefox 中访问。

In the "Tools" menu under "Web Developer"->"Scratchpad".

在“Web Developer”->“Scratchpad”下的“工具”菜单中。

Or...

或者...

Just right click on any element on your page. Select "inspect element" On the inspector toolbar, far to the right, there is a noteblock "Scratchpad", press it.

只需右键单击页面上的任何元素。选择“检查元素”在检查器工具栏上,最右边,有一个记事本“Scratchpad”,按下它。

enter image description here

在此处输入图片说明

Now you get a Javascript editor with syntax highlightning etc.. From here you can open/save your javascript source file.

现在你得到了一个带有语法高亮等功能的 Javascript 编辑器。从这里你可以打开/保存你的 javascript 源文件。

enter image description here

在此处输入图片说明

Read more bout it here.

在这里阅读更多。

回答by jalf

In the Firebug console, you can type in new javascript. So just redefine functions or variables as needed through that.

在 Firebug 控制台中,您可以输入新的 javascript。因此,只需根据需要重新定义函数或变量即可。

回答by Pavel Strakhov

You can't do it. You should use javascript console to redefine functions.

你不能这样做。您应该使用 javascript 控制台重新定义函数。

回答by LearningEveryday

You can also use fiddler.
I use it and it has worked out for me pretty well.

您也可以使用fiddler
我使用它,它对我来说效果很好。