我怎么能在我的浏览器的JavaScript编辑我一样可以使用Firebug编辑CSS / HTML? [英] How can I edit javascript in my browser like I can use Firebug to edit CSS/HTML?

查看:117
本文介绍了我怎么能在我的浏览器的JavaScript编辑我一样可以使用Firebug编辑CSS / HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JSP文件,我有一些pretty复杂的JavaScript。在一个生产机器,我们看到一个非常奇怪的错误,我们一直无法理解。我们从来没有能够复制它在本地或开发环境。这可能涉及到的JavaScript,但我还没有找到很好的办法做到这一点:用我的浏览器访问该页面(在生产网站),然后使用浏览器工具来编辑该网页上运行的JavaScript,包括在页面重新加载。

Within JSP files, I have some pretty complicated Javascript. On a production machine, we're seeing a very weird bug that we have not been able to understand. We have never been able to replicate it in a local or development environment. It might be related to the javascript, but I haven't found a good way to do this: use my browser to visit the page (on the production website) and then use browser tools to edit the javascript that runs on that page, including on reloads of the page.

我总是能做到这一点,以调整CSS等,但这些问题指出,这不是明显的如何调整JS客户端:

I'm always able to do this to tweak CSS etc, but as these questions point out, it's not obvious how to tweak JS client-side:

  • Best way to capture javascript errors in production
  • How to edit javascript in browser?
  • How to edit javascript in firebug in Mozilla?
  • How can I edit a js file sent by the server before it gets to my browser?
  • How to replace Javascript of production website with local Javascript?
  • with firefox w/firebug, how can I write javascript in the browser and use the .js file objects also?

然而,这些问题的答案不帮我,因为:

However, those answers don't help me because:


  • 执行JS(火狐插件)似乎不正常工作(不做得比在Chrome控制台更已经可以做到),

  • 如果我已经使用分离的js文件,但我的JavaScript嵌入在JSP中查可能工作

这似乎是<一个href=\"http://stackoverflow.com/questions/5191284/how-to-modify-javascript-$c$c-on-the-fly-in-browser-in-debugging-mode/5281401#5281401\">How修改JavaScript的code在调试模式在浏览器中的苍蝇?是最接近我在说什么,但那个家伙是不是能够谈论他的所作所为,因为这是对他雇主。

It seems like How to modify javascript code on the fly in browser in debugging mode? is the closest thing to what I'm talking about, but that guy isn't able to talk about what he did because it was for his employer.

感谢您的帮助!
瑞安

Thanks for your help! Ryan

推荐答案

与编辑问题的JavaScript像您可以CSS和HTML是有传播的变化没有干净的方式。 JavaScript可以修改DOM,发送Ajax请求,并在运行时动态地修改现有对象和函数。所以,一旦你已经装载了JavaScript的网页,它可能是完全不同的JavaScript的运行后。浏览器必须跟踪每次修改你的JavaScript code进行,这样当你编辑的JS,它回滚所做的更改到一个干净的页面。

The problem with editing JavaScript like you can CSS and HTML is that there is no clean way to propagate the changes. JavaScript can modify the DOM, send Ajax requests, and dynamically modify existing objects and functions at runtime. So, once you have loaded a page with JavaScript, it might be completely different after the JavaScript has run. The browser would have to keep track of every modification your JavaScript code performs so that when you edit the JS, it rolls back the changes to a clean page.

但是,你可以修改的JavaScript动态其他一些方式:

But, you can modify JavaScript dynamically a few other ways:


  • 的JavaScript注射在地址栏: JavaScript的:警报(1);

  • 通过一个JavaScript控制台(有一内置火狐,Chrome和IE的新版本

  • 如果你想修改JavaScript文件,因为它们投放到您的浏览器(即抢夺它们在运输和修改它们),那么我不能帮上什么忙。我建议用调试代理: http://www.fiddler2.com/fiddler2/

  • JavaScript injections in the URL bar: javascript: alert (1);
  • Via a JavaScript console (there's one built into Firefox, Chrome, and newer versions of IE
  • If you want to modify the JavaScript files as they are served to your browser (i.e. grabbing them in transit and modifying them), then I can't offer much help. I would suggest using a debugging proxy: http://www.fiddler2.com/fiddler2/

前两个选项是伟大的,因为你可以在范围上修改任何JavaScript变量和函数目前。但是,您将无法修改code和带有只是服务的页面一样,你可以用第三个选项运行它。

The first two options are great because you can modify any JavaScript variables and functions currently in scope. However, you won't be able to modify the code and run it with a "just-served" page like you can with the third option.

除此之外,据我所知,在浏览器中没有编辑和运行JavaScript编辑器。希望这有助于

Other than that, as far as I know, there is no edit-and-run JavaScript editor in the browser. Hope this helps,

这篇关于我怎么能在我的浏览器的JavaScript编辑我一样可以使用Firebug编辑CSS / HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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