473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

traversing JavaScript namespace

This is my problem:

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 ?

Thanks

Plamen
Jul 20 '05 #1
3 1932


Plamen Valtchev wrote:
This is my problem:

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 !

Properties marked as enumerable can be enumerated with
for (var prop in object)
The global object in client side JavaScript is the window object so you
can try
var text = '';
for (var prop in window) {
text += prop + ': ' + window[prop] + '| ';
}
alert(text);
however you will find browser dependant differences as to the properties
that are enumerated.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
"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 =---
Jul 20 '05 #3
Ivo
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

=---
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lothar | last post by:
i want to traverse a set of messages in a Yahoogroups group from a Python program. to get to the messages of the group, one must log in. this presents, i think, two problems, 1) handling the...
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
6
by: hazz | last post by:
My runtime in debug is dropping through the constructors from an upper level class into subclassed constructors..... namespace AB public class A : MarshalByRefObject public A () ...
4
by: plmanikandan | last post by:
Hi, I am new to link list programming.I need to traverse from the end of link list.Is there any way to find the end of link list without traversing from start(i.e traversing from first to find the...
4
by: Christian Rühl | last post by:
Good Day, folks! I'm having a problem traversing an XmlDocument tree in C#. I only want to access the InnerText of the leafs and the names of their ancestors and show them in a richTextBox. But...
30
by: asit | last post by:
We kno that data can be pushed onto the stack or popped 4m it. Can stack be traversed ??
5
by: tonecj | last post by:
Hi team I'm traversing an XML file with 3000 + records in it. I've now run into some serious performance issues as a consequence... Is there an alternative to the below code I'm using? Or is there...
1
by: somcool | last post by:
I am facing an error while traversing a query in MS Access Details - When I click a button, a form which has the query opens up. There are certain fields which are in the form of combo box in the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.