简体   繁体   English

停止JavaScript而不重新加载页面

[英]Stop JavaScript without reloading the page

I have some JavaScript that, I believe, is stuck in an infinite loop. 我相信,我有一些JavaScript陷入无限循环。 I know I can just reload the page, but I have data in a form on the current page that I'd like to keep. 我知道我可以重新加载页面,但是我在当前页面上有一个表格中的数据,我想保留。 The tab is completely unresponsive, so I can't just copy and paste everything and then reload. 该选项卡完全没有响应,因此我不能只复制并粘贴所有内容然后重新加载。 So is there any way to kill the javascript thread, but keep the DOM in Chrome? 那么有没有办法杀死javascript线程,但保持DOM在Chrome中?

Open chrome developer tools and go to the sources tab. 打开chrome开发人员工具并转到“源”选项卡。 On the right panel press "pause script execution". 在右侧面板上按“暂停脚本执行”。

在此输入图像描述

You can open the developer console F12 and stop the script 您可以打开开发人员控制台F12并停止脚本 在此输入图像描述

looks like someone had the same problem 看起来有人有同样的问题

Cancel infinite loop execution in jsfiddle 在jsfiddle中取消无限循环执行

Answer: 回答:

With the developer mode, go into resources and find your script and copy and paste it into a text document or a new window. 使用开发人员模式,进入资源并找到您的脚本并将其复制并粘贴到文本文档或新窗口中。 If you can't find it in resources, do a search for a variable or line of code you used. 如果在资源中找不到它,请搜索您使用的变量或代码行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM