简体   繁体   English

如何在Firebug中编辑JavaScript?

[英]How to edit JavaScript in Firebug?

I am only able to view the JavaScript files of the website via the Script panel. 我只能通过“ 脚本”面板查看网站的JavaScript文件。 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. 我尝试了所有内容,例如双击我要编辑的行等,但它不允许我编辑它。

If I move to the HTML tab, I am able to edit the HTML by clicking on the Edit button, but I am not able to edit the JavaScript. 如果我移动到HTML选项卡,我可以通过单击编辑按钮来编辑HTML,但我无法编辑JavaScript。

替代文字
(source: fidelitydesign.net ) (来源: fidelitydesign.net

You can use the Firebug Console tab to write Javascript. 您可以使用Firebug控制台选项卡编写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. 使用控制台时,javascript将在当前页面的上下文中执行。 Therefore, and scripts that are currently defined for that page, can potentionally be redefind. 因此,当前为该页面定义的脚本可能会被重新发现。 Eg, in the Console window, I could do this: 例如,在控制台窗口中,我可以这样做:

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

...and that would redefine the $ function used by JQuery. ...这将重新定义JQuery使用的$函数。

As far as I know only Chrome's dev tools support editing JavaScript inside their Sources tab (not just via the command line). 据我所知,只有Chrome的开发工具支持在Sources选项卡中编辑JavaScript(而不仅仅是通过命令行)。 And you can add an extension like Tincr or DevTools Autosave and Chrome will save the changes to your JavaScript files on the disk. 您可以添加像TincrDevTools Autosave这样的扩展程序,Chrome会将更改保存到磁盘上的JavaScript文件中。 So it is pretty much a complete IDE for 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,则必须在命令编辑器中测试代码,然后打开文本编辑器并打开您在Firebug中查找的文件,然后在文本编辑器中添加这些更改并保存。

I hope that one day they will enable JavaScript to be editable inside the Script panel of Firebug. 我希望有一天他们能够在Firebug的Script面板中编辑JavaScript。

There is a "Scratchpad" built into the Mozilla framework. Mozilla框架内置了一个“Scratchpad”。 This can be reached from within Firefox. 这可以在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”,按下它。

在此输入图像描述

Now you get a Javascript editor with syntax highlightning etc.. From here you can open/save your javascript source file. 现在你得到一个带有语法高亮等的Javascript编辑器。从这里你可以打开/保存你的javascript源文件。

在此输入图像描述

Read more bout it here . 在这里阅读更多内容。

In the Firebug console, you can type in new javascript. 在Firebug控制台中,您可以输入新的JavaScript。 So just redefine functions or variables as needed through that. 因此,只需根据需要重新定义函数或变量。

You can't do it. 你不能这样做。 You should use javascript console to redefine functions. 您应该使用javascript控制台重新定义函数。

You can also use fiddler . 你也可以使用fiddler
I use it and it has worked out for me pretty well. 我用它,它对我来说非常好。

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

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