koubin
koubin

Reputation: 607

How to apply JavaScript changes in Firebug?

I am playing around with a JavaScript code in Firebug and I would like changes to take effect in that page. Especially when there is code inside jQuery's $.ready() function.

Some kind of refreshing the page without losing of what has been edited. Is there any way to do that?

Upvotes: 0

Views: 221

Answers (3)

Sebastian Zartner
Sebastian Zartner

Reputation: 20105

Changes to pages done via Firebug do not persist. After a page reload the original sources will be loaded again (from the server or the browser cache).

Currently Firebug doesn't allow you to edit the code of the loaded scripts directly.

Though you can execute JavaScript code within the context of the page by using the Command Line: Command Line in Firebug

Or for longer scripts you can use the Command Editor: Command Editor in Firebug

But again, code you executed there will be gone as soon as the page is reloaded.

To make permanent changes to the JavaScript code of a page you need to have access to the server and make them there.

Upvotes: 1

jfriend00
jfriend00

Reputation: 707396

Page changes made via Firebug or via Javascript do not persist from one page load to another. Each time a page is loaded, the original HTML, CSS and JavaScript is parsed and loaded (from cache or from the server). Any prior changes will not be there.

The only way for a dynamic page change to be still present after a refresh is for you to save the changed state to a persistent location and then rebuilt the appropriate page content from that state each time the page is loaded.

But, if you make a change to the page and store some state in a cookie, in local storage or on your server, then you can have JavaScript that runs each time the page loads that gets that state from wherever you stored it and then applies the appropriate change to the page. If you're saving the state on the server (on behalf of this particular user), then you could even have the serve modify the page contents before it is served to the browser.

Upvotes: 2

Nelu
Nelu

Reputation: 18710

You can type JavaScript code in the Firebug command line and see changes take effect on the page. You can do the same in the Firefox, Chrome, Opera and Safari DevTools.

Firebug console

Upvotes: 1

Related Questions