[英]how can I force IE9 to “see” the most current javascript when using the debugger?
I'm using IE9 to debug a web app.我正在使用 IE9 调试 web 应用程序。 I made some changes to the javascript after loading the page.
加载页面后,我对 javascript 进行了一些更改。 I'm not able to get IE9 to stop on the new code.
我无法让 IE9 停止使用新代码。 The message is " The code in the document is not loaded ".
消息是“文档中的代码未加载”。 I can set breakpoints when I'm not debugging, but they won't be valid when I start debugging.
我可以在不调试时设置断点,但是当我开始调试时它们将无效。 I'm using IE7 Browswer Mode, IE7 Document Mode.
我正在使用 IE7 浏览器模式,IE7 文档模式。
Things I've tried:我尝试过的事情:
Next thing to try (I guess) would be closing IE completely.接下来要尝试的事情(我猜)是完全关闭 IE。 Is that the fix for this?
这是解决这个问题的方法吗? If so, yuck.
如果是这样,呸。 It takes me a couple of minutes to set the page up so doing that after every JS change really stinks.
我花了几分钟来设置页面,所以在每次 JS 更改之后这样做真的很糟糕。 I can use FF4 to develop the JS, but the JS issue I'm seeing is specific to IE7 so I have to do it this way.
我可以使用 FF4 开发 JS,但是我看到的 JS 问题是 IE7 特有的,所以我必须这样做。
>> How can I get IE9 (running in IE7 mode) to reliably debug the most current JS from the server? >>如何让 IE9(以 IE7 模式运行)可靠地调试来自服务器的最新 JS?
This issue wasn't related to caching etc. IE9 was hitting a script error (missing closing paren) in the new code and not allowing breakpoints anywhere in the script.此问题与缓存等无关。IE9 在新代码中遇到脚本错误(缺少关闭括号),并且不允许在脚本中的任何位置设置断点。 IE seemed very quiet about the script error though.
不过,IE 似乎对脚本错误非常安静。 Anyway, fixing the script error fixed the issues with breakpoints / caching.
无论如何,修复脚本错误解决了断点/缓存的问题。
If you have access to the code:如果您有权访问代码:
In you javascript file reference add a query string, something like this:在您的 javascript 文件引用中添加一个查询字符串,如下所示:
<script src="Scripts/main.js?v=1" type="text/javascript"></script>
And every time you change in the js file change the v
value to something else, like that the browser will feel that this is a new file and will get it.并且每次你在js文件中更改时,将
v
值更改为其他值,这样浏览器会觉得这是一个新文件并会得到它。
Add this:添加这个:
window.applicationCache.addEventListener('updateready', function (e)
{
if (window.applicationCache.status == window.applicationCache.UPDATEREADY)
{
window.applicationCache.swapCache();
if (confirm('A new version of this site is available. Load it?'))
window.location.reload();
}
}, false);
I found this solution somwhere in the Net.我在网络的某个地方找到了这个解决方案。 Sorry, but I don't remember the author.
对不起,我不记得作者了。 It works for me when I debug Web App with JavaScript in Visual Studio and use IE.
当我在 Visual Studio 中使用 JavaScript 调试 Web 应用程序并使用 IE 时,它对我有用。
I found this question based on the "the code in the document is not loaded" error message.我根据“未加载文档中的代码”错误消息找到了这个问题。 I'm not using IE7 document mode or any of that, just IE9.
我没有使用 IE7 文档模式或任何其他模式,只是 IE9。
Like jcollum, my issue wasn't related to caching.像 jcollum 一样,我的问题与缓存无关。
I'm using MVC.Net, and someone had set up a piece of javascript to rely on a string in the ViewBag.我正在使用 MVC.Net,有人设置了一块 javascript 来依赖 ViewBag 中的字符串。 I changed a couple things, and that ViewBag string disappeared, so the resulting javascript looked something like this:
我改变了一些东西,那个 ViewBag 字符串消失了,所以生成的 javascript 看起来像这样:
if(!()) {
// Some code
}
Javascript died right here, and wouldn't process the rest of the code in the block. Javascript 就死在这里,不会处理块中代码的 rest。 This was confusing, as it was still trying to execute javascript in a different set of script tags, but which relied on a variable set in the other block it wouldn't load.
这令人困惑,因为它仍在尝试在一组不同的脚本标签中执行 javascript,但它依赖于它不会加载的另一个块中设置的变量。
So, basically, a syntax error was introduced via strange means, and the debugger refused to load some of the code which came after it.所以,基本上,语法错误是通过奇怪的方式引入的,调试器拒绝加载后面的一些代码。 Another lesson on the dangers of ViewBag.
关于 ViewBag 危险的另一个教训。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.