It 's an interesting idea, using javascript to analyse javascript. The
actual scripts on a page are stored in the DOM under "document.scripts",
with "text" and "src" as the most useful branches.
If it is an inline script, you can break up document.scripts[n].text with a
regular expression:
txt = document.scripts[0].text; // first script tag on the page
reg = /function\s*?(\w+)\s*?\(([,\w\s]*?)\)/gm; // searches function names
if( list = txt.match(reg) )
alert( list.join('\n') );
else
alert( 'No functions in this script!' );
External scripts are a bit more difficult. I have found myself loading
document.srcipts[n].src into a hidden textarea to let the code 'read' the
code. Less clumsy solutions are welcome!
HTH
Ivo
"Ira Baxter" <id******@semdesigns.com> wrote in message
news:40********@giga.realtime.net...
"Plamen Valtchev" <pl****@genient.com> wrote in message
news:82**************************@posting.google.c om...
From JavaScript I want to find the list of all defined/loaded
JavaScript functions/objects/names within the current scope (html page
in a browser).
the page could contain many included javascript with the script tag :
<script language="javascript" src="XXX/Script.js"></script>
and I wont to know the functions that have been loaded from the
included script
I couldn find any way of traversing the JavaScript namespace atall !
any ideas ?
You could use a real JavaScript parser that understood HTML to figure
this out off line. See
http://www.semdesigns.com/Products/F...tFrontEnd.html
--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000
Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---