Jump to content

how to get the function source


seco

Recommended Posts

I assume you haven't written the js yourself is this correct? To find the corresponding function you should ask yourself "when" the function is called and "what" it does. Do you have this page online or can you isolate the js code that is responsible for this action you seek? It would be easier with the actual code right now people on this forum can only guess.

Link to comment
Share on other sites

the function source is inside a js file and there is too much js files on the page

Technically you already have it then you just don't know which part is responsible for your function call

on my page i have a function called many times  and i want to its source how?

When is this function called?

Link to comment
Share on other sites

Mozilla supports fn.toSource() ,  and both Mozailla and IE support fn.toString();

 

With these, you can override existing functions;

 

elm.oldclick = elm.onclick;
elm.onclick = function()
{
     eval( this.oldclick.toString().replace(/black/g,'white') );
};

 

something like that.

Link to comment
Share on other sites

thanks for reply

on firebug console i write obj.func.toSource();

and it gives me the function source detail written but it didn't gives me the source js file !!

how to get the js file that contains this function?

 

thanks in advance.

 

Link to comment
Share on other sites

thanks for reply

actually both methods gives me the function source

ok where is the js file that contains that source?

 

and i have second question

how to watch any click event on the page?

because i want to get the function that is called when clicking a button

thanks in advance.

 

Link to comment
Share on other sites

To my knowledge, there's no way to trace a function back to the script tag/src that loaded it. In fact, you don't even need the tag anymore.

 

I've done this in an 'include' script, that does two things.

- loads a script

- removes it right away.

 

Once parsed, the contents reside somewhere in the browser's magic brain, which varies by vendor.

 

Capturing click events isn't very hard, but be aware of capture vs bubble:

http://www.quirksmode.org/js/events_advanced.html

 

I'd probably start a new thread for that

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.