0

I have a website with javascript and when I move my mouse on that website, there is function triggered. I need to debug whole javascript code step by step when it is executed. I need to find out which function is called (and parameters too).

How can I do this - what should I use for this? Any real time debugger?

EDIT: Now I see it is script loaded from another url (my site is mydomain.tld, second script loads from seconddomain.tld). Second script is obfuscated/minimized and it control clicks on website (when clicked, it triggers one function). Is it possible with javascript on my site to call function in that second script? If yes, how please.

1
  • Hope you will not work on compressed version of js . OtherYou can use the debugger and place a break point .Use chrome developer's tool. Commented Jan 28, 2016 at 10:19

5 Answers 5

1

Just put the command debugger anywhere and Chrome will stop there when it happens to pass that place by.

Don't forget to keep the debugger open by pressing F12

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

Comments

1

I need to find out which function is called

In console (Firebug, Developer tools, etc.) you can click Profile button or use commands:

console.profile();
//...
console.profileEnd();

And it will display what functions were called during the profiling.

Then you can use debugger; command inside the functions as everyone mentions.

4 Comments

I tried this with this fiddle and the console only outputs Profile 'Profile 1' finished..
@E.Sundin jsFiddle is not good place to use nor test console commands because the code runs in iFrame.
I tested it locally and it shows the same result as the fiddle. Could you provide an example which you know works?
@E.Sundin Try to look into documentation for your console. For example in Firebug in prints directly into console but in Chrome the results are only on Profiles tab.
1

If site uses jQuery then you can go to the function source with Chrome DevTools. Go to event listener sidebar in elements panel, expand interesting event and click the link to source.

E.g. input#new-todo has internal jQuery listener but DevTools has resolved it and show link to user defined function outside framework. Event listener sidebar

Comments

0

You can use Chrome for that. You can add breakpoint.

See the doc https://developer.chrome.com/devtools/docs/javascript-debugging

Comments

0

you can track mouse move event by

<script> $(document).mousemove(function(event){console.log(event);}); </script>

and open console window in browser when mouse move it will display all things...

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.