seco Posted June 1, 2009 Share Posted June 1, 2009 Hi i have firebug installed on my page i have a function called many times and i want to its source how? can firebug help me? how? thanks in advance. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 1, 2009 Share Posted June 1, 2009 Do you mean a javascript function on the page ??? If so it should be viewable by checking the html tab Quote Link to comment Share on other sites More sharing options...
seco Posted June 1, 2009 Author Share Posted June 1, 2009 yes js function and i want to get its source on html tab there is the page source and there is many js files included how to get the function definition? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 1, 2009 Share Posted June 1, 2009 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. Quote Link to comment Share on other sites More sharing options...
seco Posted June 1, 2009 Author Share Posted June 1, 2009 the function source is inside a js file and there is too much js files on the page how to get the source ? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 1, 2009 Share Posted June 1, 2009 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? Quote Link to comment Share on other sites More sharing options...
seco Posted June 2, 2009 Author Share Posted June 2, 2009 thanks for reply exactly Dj Kat it's called on click event of the button like this onclick='func.getit' how to get the definition ? Quote Link to comment Share on other sites More sharing options...
bibby Posted June 2, 2009 Share Posted June 2, 2009 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. Quote Link to comment Share on other sites More sharing options...
seco Posted June 3, 2009 Author Share Posted June 3, 2009 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. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 In Firebug console, put this in and run it: window.alert(func.getit); Quote Link to comment Share on other sites More sharing options...
seco Posted June 3, 2009 Author Share Posted June 3, 2009 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. Quote Link to comment Share on other sites More sharing options...
bibby Posted June 3, 2009 Share Posted June 3, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.