Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome and JS onclick function?

I wanted to test chrome to see if it can show me what method will be running for onclick registered event.

So I wanted to see which JS function execute shen people upvotes a question :

http://i.stack.imgur.com/3mbce.jpg

enter image description here

But I couldn't found the actual code.

is it possible with chrome to find which JS executes when "onclick"?

edit

I could use the console to do it with :

$.each($(".vote-up-off").data("events"), function(i, e) {  // this will work till jq 1.8
  console.log(this)
});

and here is our friend:

enter image description here

But hey ! , I want chrome to do the work :-)

like image 722
Royi Namir Avatar asked Feb 16 '13 12:02

Royi Namir


People also ask

Can we use onclick in JavaScript?

Note that the onclick attribute is purely JavaScript. The value it takes, which is the function you want to execute, says it all, as it is invoked right within the opening tag. In JavaScript, you invoke a function by calling its name, then you put a parenthesis after the function identifier (the name).

Why JS is not working in Chrome?

Google ChromeIn the "Settings" section click on the "Show advanced settings..." Under the the "Privacy" click on the "Content settings...". When the dialog window opens, look for the "JavaScript" section and select "Allow all sites to run JavaScript (recommended)". Click on the "OK" button to close it.

Is Onclick and click Same?

click is a function on HTML elements you can call to trigger their click handlers: element. click(); onclick is a property that reflects the onclick attribute and allows you to attach a "DOM0" handler to the element for when clicks occur: element.

Where is JavaScript function in Chrome?

To find the JavaScript function definition in Google Chrome, open the web browser and press F12 to reach Developer Tools. Search for function and that's it.


2 Answers

One potential insight might be to enter this in your console and press return:

$('.vote a').data('events').click;

jQuery stores all of its events which are bound to an object inside of the data() object; so if you want to view a particular event binding, this is your place to look. Console will return an object. Expand handler --> <function scope> --> Closure and you can now see all of the associated JavaScript around this click event.

like image 52
hohner Avatar answered Sep 25 '22 22:09

hohner


some workarounds available U may try this bookmarklet concept Visual Event

Add bookmarklet to you browser bookmarks(enable bookmarks bar show always) and click on bookmark while on the page u want to debug

PS: it is for Jquery

like image 30
mermerkaya Avatar answered Sep 22 '22 22:09

mermerkaya