在Chrome开发人员工具中编写JavaScript [英] Write JavaScript in Chrome developer tools

查看:122
本文介绍了在Chrome开发人员工具中编写JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firebug中,我可以在控制台选项卡中键入自己的JavaScript并执行它.有没有一种方法可以在Chrome开发者工具中键入JavaScript并执行它?

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?

推荐答案

  1. 转到chrome://flags/,启用启用开发人员工具实验"标志,然后重新启动Chrome(或使用--enable-devtools-experiments命令行标志启动它.)
  2. 打开DevTools,转到Settings对话框,切换到Experiments选项卡.
  3. 启用代码段支持"实验,关闭并重新打开DevTools.
  4. 转到Sources面板.在左侧导航器的侧栏中,切换到Snippets标签.
  5. 右键单击此选项卡中的[空白]树,选择New上下文菜单项.
  6. 为新代码段提供任何您喜欢的名称,然后输入代码段正文.
  7. 完成后,单击状态栏中的Run(>)按钮以执行代码段主体.您可以在摘要中设置断点,并将其作为普通脚本进行调试.
  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.

这篇关于在Chrome开发人员工具中编写JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆