how do i get all functions
1 posts in topic
Flat View  Flat View

Posted By:   danish_qamar
Posted On:   Friday, January 10, 2003 11:37 PM

how do i get all the functions on the current page.
document.scripts returns all the script how do i get all the function names ?? someone told me there is a function object though it doesn't holds all the function's information but that can help me. i can't get it helping me. nyway can nyone please tell me ?

Re: how do i get all functions

Posted By:   Sandip_Chitale  
Posted On:   Saturday, January 11, 2003 09:54 AM

See my post for details -


This works for inline scripts only. This works for top level functions only (i.e. non-nested). You will have to
do more for 'src' loaded scripts.

function dumpFunctions(win)
var functionMatcher = new RegExp("function\s+([a-zA-Z0-9_]+)\s*\(", "g");

for (var i = 0; i < win.document.scripts.length; i++) {
if (win.document.scripts[i]) {
var scriptText = win.document.scripts[i].text;
if (scriptText) {
var matched;
while ((matched = functionMatcher.exec(scriptText)) != null) {
About | Sitemap | Contact