Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out what javascript runs when I click an element? [duplicate]

Tags:

javascript

I am looking at the Bing Maps site. I am opening up the my places editor and clicking the polyline tool in the drawing toolbar.

I would like to discover what javascript runs when I click on tools in the drawing toolbar.

I have looked at the html and there is no onclick event declared on the element.

I have done text searches on all of the scripts referenced by the page, for the ID of the polyline tool element. This was to try to find javascript that attaches a click event to the element, but I got no matches at all.

There must be some script running when I click on a tool. How do I find out what script is executing when I click the tool divs in the toolbar?

I don't think there is anyway I can set breakpoints if I don't first know what script to set them on. Is there anyway I can trap the javascript that runs to discover what it is, either in IE F12 developer tools or in firebug?

like image 423
Duncan Gravill Avatar asked Apr 21 '12 20:04

Duncan Gravill


People also ask

How do you check if a value is repeated in an array JavaScript?

To check if an array contains duplicates: Use the Array. some() method to iterate over the array. Check if the index of the first occurrence of the current value is NOT equal to the index of its last occurrence. If the condition is met, then the array contains duplicates.

How do you find a repeated value in an array?

function checkIfArrayIsUnique(myArray) { for (var i = 0; i < myArray. length; i++) { for (var j = 0; j < myArray. length; j++) { if (i != j) { if (myArray[i] == myArray[j]) { return true; // means there are duplicate values } } } } return false; // means there are no duplicate values. }


2 Answers

You can have a look at the "Event Listeners" panel in Chrome, it has detailed information about each listener attached to an element.

enter image description here

like image 93
Dagg Nabbit Avatar answered Sep 18 '22 05:09

Dagg Nabbit


In Chrome Developer Tools click on the timeline tab, uncheck "Loading" and "Rendering", then click the record button (filled circle). Trigger your event by clicking on the button and then stop recording by clicking the circle again. Find your event in the timeline and expand it by clicking on the arrow beside it. On the left it will tell you which function the event called.

like image 31
Paul Avatar answered Sep 20 '22 05:09

Paul