5

I have an issue I'm trying to debug on our website, where a particular javascript routine is not being found. I'm at a loss to identify why, but my thinking is that if the F12 Dev tools can't reach the code for some reason, then anything in that script block is inaccessible and will not be executed.

Is there somewhere I can look to for an explanation of why code in one script block is reachable, and another, seemingly identical block is unreachable?

Illustration of reachable and unreachable code

Daniel Bragg
  • 1,773
  • 1
  • 12
  • 25
  • Is it possible that a syntax error somewhere in the second block invalidates the entire block? – Daniel Bragg Apr 13 '17 at 21:59
  • 1
    Could you please post code/screenshot of the scripts above the error point and also could you please tell me if the same occurs on other web browsers? – Sagar Apr 19 '17 at 07:34
  • More code above the error point? I've identified working code (see active breakpoint and script close/open tags in the screenshot) above the error, and have verified that it does reach and break on that code. Also, by "other web browsers" do you mean non-IE 11 browsers, or IE 11 browsers on other computers? – Daniel Bragg Apr 20 '17 at 19:10
  • I do mean non-IE browsers. Because its rare though not impossible to have cross browser issues on scripts. – Sagar Apr 21 '17 at 11:51
  • @Dan Would it be possible for you to post the full that is not reachable instead of just the one line? – Ken Apr 24 '17 at 20:15
  • @Dan, is the code reachable in other Non-IE browsers? Also, what is up with the `language=JavaScript` attribute? I've never seen in that in a `script` tag – Maria Ines Parnisari Apr 25 '17 at 17:33

3 Answers3

2

replace with language="javascript" or remove language="JavaScript"

As per https://msdn.microsoft.com/en-us/library/ms533940(v=vs.85).aspx for attribute language.

javascript

Script is JavaScript.

Please refer this and this

Community
  • 1
  • 1
Vikas Sardana
  • 1,593
  • 2
  • 18
  • 37
  • Unfortunately, I timed this bounty poorly, as I am on a week's worth of vacation. However, I think there is enough merit to this (and links I can follow-up on) that I'm going to award the bounty to you. I'll follow up on this when I get back to work, and hopefully this is enough of what I needed. However, IE 11 is usually quite forgiving about case, so I'm not convinced (and, there are no errors about it being an invalid value.) – Daniel Bragg Apr 26 '17 at 00:46
  • 1
    If I find this isn't the case, hopefully I can return to you for some other suggestions? – Daniel Bragg Apr 26 '17 at 00:49
0

Although I awarded the bounty to the first post, the actual answer is that an error in the second block of javascript invalidates the entire block for breakpoint handling.

To diagnose this (if the code isn't your own, or you wrote it a long time ago and have forgotten where you made changes) is to break each routine into its own separate block, then find the block that is still failing. Then, go through that routine with a fine-toothed comb to determine the cause of the syntax failure -- be thorough!

Once I identified the cause (a misplaced semicolon), then breakpoints were re-enabled for the entire block.

Other causes could be that the code block is unreachable, due to duplicate function names. That wasn't my case, however, so I didn't confirm this as a possible cause of unreachable breakpoints.

Daniel Bragg
  • 1,773
  • 1
  • 12
  • 25
-2

It seems like the function positionCollectionList() call is returning in the end and the next block of code in your case strDGLabel_ContributingFactors hadn't been enclosed in any function so that it can't be called or executed which means it is unreachable code.

For making sure you can try the following example

Try to save the below code as a html file and open it in IE and then try to keep a breakpoint at line 8 you will reproduce the issue.

<html>
<script>
var te;
</script>
<script>
var test="testing";
return;
te="test";
</script>
<body>
HI
</body>
</html>

Thanks

visrey
  • 423
  • 6
  • 12
  • Thanks, but the code block above is very much incomplete (lack of an opening – Daniel Bragg Apr 26 '17 at 00:48