Monday, 29 December 2014

Debugging in IE with Visual Web Developer: Breakpoint cannot be set in this location, the code in the document is not loaded

Today I was testing one of my websites in IE7, and had an error message popping up, saying there was a javascript error, and would I like to debug it. So I clicked Yes, but nothing happened.

I opened Visual Web Developer 2010 Express to start debugging from that, since there is no Developer Tools for debugging js in old versions of IE. I started debugging, loaded the page, and got the same message. Clicked OK to debug, but nothing happened still. In Visual Web Developer it had opened the js file where the error had occured, but it hadn't paused the script at all. I couldn't see any error at the line the error was occuring.

So I tried adding a breakpoint before where the error was occuring, but the breakpoint was a yellow outline of a circle with a small warning notice, rather than the usual filled red circle. Hovering the mouse over the breakpoint gave a tooltip that stated Breakpoint cannot be set in this location, the code in the document is not loaded. Strangely I couldn't set any breakpoints at all in this script file, they all gave the same result (and wouldn't be hit when running the page, yet the error caused by that script file was still occuring).

I found a list of suggested solutions here: ie8 javascript not running or loading. However, none of them helped. Eventually I had to try commenting out a block of js in the javascript file, refreshing and seeing if the error still occured. If not, comment out a smaller block to try and find exactly where the error was occuring.

After doing this I found what the issue was, and it was about where IE said it was (technically IE gave the correct line number, but I needed to look very carefully at the line above to spot the error). The problem was that I was declaring an object with various properties, but I had a trailing comma after the last property. So IE was being better than the other browsers by flagging this, and it was just a case of me not being able to spot the issue.

1 comment:

Anonymous said...

Hey there! I just had an outstanding experience at a hearing aid service center and felt compelled to share it. If you’re experiencing hearing difficulties and are in the market for a hearing aid, this place is definitely worth a visit. The staff were not only professional but also incredibly kind and attentive. They conducted a detailed hearing test and offered a range of hearing aids to fit my needs perfectly. The technology they use is state-of-the-art, providing superb sound quality and comfort. My new hearing aid has made a huge difference in my daily interactions. If you’re thinking about getting a hearing aid, make sure to visit this place. For more information, visit https://hearwellservices.com/.