摆脱 Visual Studio 中的 [动态] JavaScript 视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13726430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 12:45:06  来源:igfitidea点击:

Get rid of [dynamic] JavaScript views in Visual Studio

javascriptvisual-studio-2010debugging

提问by chiccodoro

Since I installed Visual Studio 2010 from scratch about 2 months ago, it behaves slightly different when debugging JavaScript code being run in IE.

由于我大约 2 个月前从头安装了 Visual Studio 2010,因此在调试在 IE 中运行的 JavaScript 代码时,它的行为略有不同。

  • When I set a breakpoint, it opens a duplicate of the view with the term "[dynamic]" in the header and marks the breakpoint in there.
  • When a JavaScript error happens during execution, it does the same before it marks the line of code that threw the error.
  • This "dynamic" view is editable but edits have no effect - they are not saved to the file.
  • 当我设置断点时,它会在标题中打开带有术语“[dynamic]”的视图副本,并在其中标记断点。
  • 当 JavaScript 在执行过程中发生错误时,它会在标记抛出错误的代码行之前执行相同的操作。
  • 这个“动态”视图是可编辑的,但编辑没有效果——它们不会保存到文件中。

I find this behavior pretty uncomfortable. Everytime I notice an error in the code during debugging, I happen to fix it in the dynamic view. I hit save. VS does not complain. Next I refresh the page in IE, and - bang - the changes are lost, it loads the untouched old version again.

我觉得这种行为很不舒服。每次我在调试过程中发现代码中的错误时,我都会在动态视图中修复它。我点击保存。VS 没有抱怨。接下来我在 IE 中刷新页面,然后 - 砰 - 更改丢失,它再次加载未修改的旧版本。

I haven't been able to find out how I can turn these views off. Before I re-installed Visual Studio it did not do that. It would only create "dynamic" views for script found in inline script tags in HTML files.

我一直无法找到如何关闭这些视图。在我重新安装 Visual Studio 之前,它没有这样做。它只会为 HTML 文件中的内联脚本标记中的脚本创建“动态”视图。

回答by Dhana Krishnasamy

Try this IE > Internet Options > Settings (under browsing history) > Check for new version of stored pages : Every time I visit the webpage.

试试这个 IE > Internet 选项 > 设置(在浏览历史记录下)> 检查存储页面的新版本:每次我访问网页时。

This works for me in IE10.

这在 IE10 中对我有用。

enter image description here

在此处输入图片说明

Other option is to open Developer tools and select cache option Always Refresh from Serveras show in the image below

其他选项是打开开发人员工具并选择缓存选项始终从服务器刷新,如下图所示

enter image description here

在此处输入图片说明

回答by Zain Rizvi

Try hitting CTRL+F5 on the web page. That did the trick for me.

尝试在网页上按 CTRL+F5。这对我有用。

The problem was that I had opened other IE windows from a previous debugging session, so the dynamic javascript files were still cached.

问题是我在之前的调试会话中打开了其他 IE 窗口,所以动态 javascript 文件仍然被缓存。

回答by Benjineer

Having developer tools open - F12- should also cause the cache files for the page to be cleared on each refresh.

打开开发人员工具 - F12- 还应该导致在每次刷新时清除页面的缓存文件。

回答by Martin Connell

Changing the encoding of the JS file in question, from a Windows codepage to UTF-8, fixes this for me.

将有问题的 JS 文件的编码从 Windows 代码页更改为 UTF-8,为我解决了这个问题。

Narrowing it down, it appears that OEM Extended ASCII characters in the file (e.g. ALT-254 which I use for a bullet) trigger the problem with the Windows codepage files.

缩小范围,文件中的 OEM 扩展 ASCII 字符(例如我用于项目符号的 ALT-254)似乎触发了 Windows 代码页文件的问题。

(Visual Studio 2013 Update 5, IE11)

(Visual Studio 2013 更新 5,IE11)

回答by mkb

For Google Chrome:

对于谷歌浏览器:

  • Open developer tools(F12)
  • Open Network ConditionsTool
  • Select Disable Cache
  • 打开开发者工具(F12)
  • 打开Network Conditions工具
  • 选择 Disable Cache

enter image description here

在此处输入图片说明

回答by MartinDuo

I had the same problem of not being able to hit a break point in new code. And breakpoints on old code in the same page will bring up the [dynamic] version. The edited page is not reloaded. This just started for me a week ago in both VS2012 and VS2013. Using refresh page and/or Ctl-F5 did not work for me. BUT, reading this thread pointed me to using F12 to open Developer tools. Leaving that window open, while hitting refresh does the trick. Thanks guys.

我遇到了同样的问题,无法在新代码中找到断点。同一页面中旧代码上的断点将调出 [动态] 版本。编辑的页面不会重新加载。这对我来说是一周前在 VS2012 和 VS2013 中开始的。使用刷新页面和/或 Ctl-F5 对我不起作用。但是,阅读此线程后,我将使用 F12 打开开发人员工具。让那个窗口保持打开状态,同时点击刷新就可以了。谢谢你们。

回答by Ray

1) Run the page Without Debugging (Debug-->Start Without Debugging)

2) While the web page is open in Internet Explorer, press Ctrl-F5 so that the IE cache is cleared. Ensure IE has the focus.

3) Close IE and re-run the page with Debugging (Debug-->Start Debugging).

1)不调试运行页面(Debug-->Start Without Debugging)

2) 在 Internet Explorer 中打开网页时,按 Ctrl-F5 以清除 IE 缓存。确保 IE 具有焦点。

3) 关闭 IE 并重新运行带有 Debugging 的页面(Debug-->Start Debugging)。

This fixed the issue for me.

这为我解决了这个问题。