Reputation: 4421
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.
Upvotes: 0
Views: 1101
Reputation: 744
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...
Upvotes: 0
Reputation: 131
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.
Upvotes: 1
Reputation: 3098
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.
Upvotes: 1
Reputation: 23848
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
Upvotes: 1
Reputation: 8386
You can use Chrome for that. You can add breakpoint
.
See the doc https://developer.chrome.com/devtools/docs/javascript-debugging
Upvotes: 0