Write JavaScript in Chrome developer tools

后端 未结 4 1112
南笙
南笙 2020-12-12 14:56

In Firebug, I can type my own JavaScript in the console tab and execute it. Is there a way to type JavaScript in Chrome Developer Tools and execute it?

4条回答
  •  抹茶落季
    2020-12-12 15:24

    1. Go to chrome://flags/, enable the "Enable Developer Tools experiments" flag and restart Chrome (or start it with the --enable-devtools-experiments command-line flag.)
    2. Open DevTools, go to the Settings dialog, switch to the Experiments tab.
    3. Enable the "Snippets support" experiment, close and reopen DevTools.
    4. Go to the Sources panel. In the left-hand navigator sidebar, switch to the Snippets tab .
    5. Right-click in the [empty] tree in this tab, select the New context menu item.
    6. Give the new snippet any name you like and type the snippet body.
    7. Once done, click the Run (>) button in the status bar to execute the snippet body. You can set breakpoints in snippets and debug them as ordinary scripts.

提交回复
热议问题