How to edit JavaScript in Firebug?

I am only able to view the JavaScript files of the website via the Script panel. 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.


Solution 1:

alt text
(source: 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:

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

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

Solution 2:

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

In the "Tools" menu under "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.

enter image description here

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

enter image description here

Read more bout it here.

Solution 3:

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

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.

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

Solution 4:

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

Solution 5:

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