0

I'm working on a project at work fixing tickets and debugging and such. And I came to a point where I need to see what the Javascript is returning and what values it gets.

The problem is as follows:

This Javascript is in the jsp file which is being shown, so its not in a separate file. Because of this Chromes Dev Tool does not show it. And it does not let me put a breakpoint in the jsp file. In the page it self. So that I may check the values and to see if everything is okey in the local scope. The code is not mine, so id like to make the least amount of changes to it as possible.

Now the question is, is there anyway other than refactoring and putting the Javascript in another file, to see whats happening while its being run. Or maybe im just missing some kind of feature that Chromes Dev tool has. Im not that experienced with all of its features to be totally honest.

Thank you in advance! And I'm sorry if something is not clear. I will edit it to make things clearer. If that is the case.

6
  • The JavaScript is still being run, so whatever file it is getting it from is being loaded. (Sorry if this is what you're already doing. Just making sure we're on the same page.) Go to Dev tools > Sources > (left hand side) sources tab > look in the cloud icon with your web domain next to it > your file with the JavaScript. Commented Sep 1, 2016 at 10:12
  • Or you can right-click that domain > search in all files. Commented Sep 1, 2016 at 10:12
  • @Leon: you wrote "This Javascript is in the jsp file which is being shown, so its not in a separate file. Because of this Chromes Dev Tool does not show it.". The chrome dev tool actually does also show the Scripts from the main HTML page itself and allows you to use breakpoints for it too. Commented Sep 1, 2016 at 10:14
  • That is the first thing I did :). I searched all the loaded files. But for some odd reason its not willing to show the script in the search results. Commented Sep 1, 2016 at 10:19
  • @igorshmigor Seems im missing something then. It does not show it in the search nor does it let me put a break point there. Commented Sep 1, 2016 at 10:20

2 Answers 2

1

What you're trying to do is add a breakpoint. Here is the reference: https://developers.google.com/web/tools/chrome-devtools/debug/breakpoints/add-breakpoints?hl=en

What you have to do is click on the gutter at the left side of the code.

Sign up to request clarification or add additional context in comments.

Comments

0

It is better to have your JavaScript in a separate file to your JSP, and just include the path in a <script> tag, so that you can take advantage of the caching capabilities in the browser.

However, you should be able to debug your JavaScript as is. If you place a debugger; statement into the JavaScript part of your JSP, when the browser evaluates the code, the debugger will detect the statement and pause, allowing you access to your client side scope.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.