Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

javascript - 在Chrome调试器中进行编辑(Editing in the Chrome debugger)

How do I "dynamically" edit JavaScript code in the Chrome debugger?

(如何在Chrome调试器中“动态”编辑JavaScript代码?)

It's not for me, so I don't have access to the source file.

(它不适合我,所以我无权访问源文件。)

I want to edit code and see what effects they have on the page, in this case stopping an animation from queuing up a bunch of times.

(我想编辑代码并查看它们在页面上有什么效果,在这种情况下,停止动画排队很多次。)

  ask by Tom translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I came across this today, when I was playing around with someone else's website.

(今天我遇到了这个,当时我和其他人的网站一起玩。)

I realized I could attach a break-point in the debugger to some line of code before what I wanted to dynamically edit.

(我意识到我想要动态编辑之前 ,我可以在调试器中附加一个断点到某些代码行 。)

And since break-points stay even after a reload of the page , I was able to edit the changes I wanted while paused at break-point and then continued to let the page load.

(而且由于断点在重新加载页面之后仍然存在 ,我能够在断点处暂停时编辑我想要的更改,然后继续让页面加载。)

So as a quick work around, and if it works with your situation:

(因此,快速解决,如果它适用于您的情况:)

  1. Add a break-point at an earlier point in the script

    (在脚本的早期位置添加断点)

  2. Reload page

    (重新加载页面)

  3. Edit your changes into the code

    (将更改编辑到代码中)

  4. CTRL + s (save changes)

    (CTRL + s (保存更改))

  5. Unpause the debugger

    (取消暂停调试器)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...