你如何在浏览器中编辑的Javascript? [英] How do you edit Javascript in the browser?

查看:125
本文介绍了你如何在浏览器中编辑的Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方式在浏览器,如Firefox进行编辑的JavaScript,在飞行并执行它。萤火虫让我们可以在飞行中编辑HTML和CSS,但JavaScript是一种痛苦。我得去回源和修改。

I was looking for a way to edit JavaScript in a browser, such as Firefox, on the fly and execute it. Firebug allows us to edit HTML and CSS on the fly but JavaScript is a pain. I have to go back to the source and modify that.

我不明白为什么浏览器的开发者工具不允许编辑。有没有办法做到这一点?

I don't understand why the browser developer tools don't allow editing. Is there a way to do it?

[更新]:
2015年标志着一个新的答案

[Update]: Marked a new answer in 2015

快速指针:


  • IE现在提供的最好的开发/调试体验有一个

  • Chrome提供的智能感知,同时编写JavaScript,这是很酷

  • FF工作方式相同,在2010年..!

我们可以使用所有这三个(火狐,IE和Chrome)浏览器控制台更新现有的功能:说我有一个函数 A()它用来做的console.log('A'),我可以去安慰,重新定义函数 A()警报('A')并再次执行看到一个警告框。

One can use all three (Firefox, Internet Explorer, and Chrome) browser consoles to update an existing function: say I had a function a() which used to do console.log('a'), I can go to console, redefine the function a() as alert('a') and execute it again to see an alert box.

当我问到这个问题,2010年,浏览器没有那么大的调试JavaScript,也是我很可能不知道,一个功能可以即时更换。

When I had asked this question in 2010, browsers were not so great at debugging JavaScript and also I was probably unaware that a function can be replaced on the fly.

推荐答案

在Chrome浏览器:打开Chrome DevTools - >源面板,浏览左侧导航,或preSS <大骨节病>控制< /骨节病> +包含在页面<大骨节病> 0 打开文件。

In Chrome: Open Chrome DevTools -> Sources panel, browse in left navigation, or press Ctrl+O to open files included in the page.

然后就可以编辑文件和preSS <大骨节病>控制 + <大骨节病>取值保存更改,并看到新的codeS会发生什么。我通常的破发点

Then you can edit the file and press Ctrl+S to save the change, and see what happens with the new codes. I usually do it with the help of break points.

如果你正在调试,并希望将更改保存到本地文件系统中,你可以右键点击导航,并选择添加文件夹复制到工作区

If you are debugging and want to save the changes to your local file system, you could right click on the navigation, and select Add folder to workspace:

在这种情况下,如果您保存DevTools的更改,在文件系统相关的文件也将被更新。

In such case, if you save your changes in DevTools, the relevant file in your file system will be updated as well.

例如我的文件夹添加到工作区中,它有一个 1.js

For example I add a folder to workspace, in it there is a 1.js:

然后我编辑DevTools JS文件,变化在立即本地文件系统更新:

Then I edit the JS file in DevTools, the change is updated in local file system immediately:

这篇关于你如何在浏览器中编辑的Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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