开发者

how can I force IE9 to "see" the most current javascript when using the debugger?

I'm using IE9 to debug a web app. I made some changes to the javascript after loading the page. I'm not able to get IE9 to stop on the new code. 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.

Things I've tried:

  • close dev tools window, re-open
  • stop debugging, start debugging
  • Ctrl R in dev tools window (same as Clear Browser Cache button)
  • Ctrl R on the IE9 web page
  • Ctrl F5 on the Ie9 web page
  • Clear browser cache for this domain
  • Check (set) Always refresh cache from server

Next thing to try (I guess) would be closing IE completely. 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. 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.

>> How can I get IE9 (running in IE7 mode) to reliably debug the most current JS from the server?


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. IE seemed very quiet about the script error though. 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:

<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.


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.


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.

Like jcollum, my issue wasn't related to caching.

I'm using MVC.Net, and someone had set up a piece of javascript to rely on a string in the ViewBag. I changed a couple things, and that ViewBag string disappeared, so the resulting javascript looked something like this:

if(!()) {
    // Some code
}

Javascript died right here, and wouldn't process the rest of the code in the block. 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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜