Closed Thread Icon

Topic awaiting preservation: Finding functions in javascript Pages that link to <a href="https://ozoneasylum.com/backlink?for=8841" title="Pages that link to Topic awaiting preservation: Finding functions in javascript" rel="nofollow" >Topic awaiting preservation: Finding functions in javascript\

 
Author Thread
amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 08-31-2003 23:21

If I have a function like this,

function test(){alert('Hi');}

and then use an alert like this,

alert(test);

it returns the code of the function, but how can I find all Javascript-functions on page, so I can step through them all one by one?


(^-^)b

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-31-2003 23:48

Well, all global functions are properties of the Window object. Combined with the typeof operator, you might be able to find a way to get a list of all the functions.

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 09-01-2003 00:02

Uhm.. I'm ashamed to ask almost.. what do you mean with the 'typeof'?


(^-^)b

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 09-01-2003 00:43

Nevermind, I got it.

function findScripts()
{
var x="";
for(i=0;i < document.scripts.length;i++)
{
x+=document.scripts[i].text;
}
alert(x);
}

(^-^)b

« BackwardsOnwards »

Show Forum Drop Down Menu