473,387 Members | 3,684 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,387 software developers and data experts.

How would I enumerate all the scripts available to a web page?

Hello

I have a web page which uses a js file on the server. I cannot see all the
javascript functions available to me in the html. I would like to have a
function which could print eg to a DIV section, all the available functions.
Just the function names is fine.

Is there any way to do this in javascript?

Angus
Apr 15 '07 #1
12 4316
Angus wrote on 15 apr 2007 in comp.lang.javascript:
I have a web page which uses a js file on the server. I cannot see
all the javascript functions available to me in the html. I would
like to have a function which could print eg to a DIV section, all the
available functions. Just the function names is fine.
Why not download the js.file and read it in notepad?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 15 '07 #2
Angus said the following on 4/15/2007 5:26 PM:
Hello

I have a web page which uses a js file on the server. I cannot see all the
javascript functions available to me in the html. I would like to have a
function which could print eg to a DIV section, all the available functions.
Just the function names is fine.

Is there any way to do this in javascript?
Yes.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 15 '07 #3
Yes I realise I can do that. I am trying to automate some web pages and
need to be able to enumerate javascript functions available programmatically
(well via javascript).

Is there some sort of script collection? Or some way of enumerating the
javascript objects programmatically?

"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
Angus wrote on 15 apr 2007 in comp.lang.javascript:
I have a web page which uses a js file on the server. I cannot see
all the javascript functions available to me in the html. I would
like to have a function which could print eg to a DIV section, all the
available functions. Just the function names is fine.

Why not download the js.file and read it in notepad?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Apr 15 '07 #4
On Apr 15, 3:26 pm, "Angus" <nos...@gmail.comwrote:
Hello

I have a web page which uses a js file on the server. I cannot see all the
javascript functions available to me in the html. I would like to have a
function which could print eg to a DIV section, all the available functions.
Just the function names is fine.

Is there any way to do this in javascript?

TRY this:

function FuncList(DIV){
for(var funcs in window)
if(typeof(window[funcs])=="function"){
var tnode=document.createTextNode(funcs)
DIV.appendChild(tnode)
}
}

the above will print all the global functions.

Apr 15 '07 #5
On 15 Apr, 22:55, "scripts.contact" <scripts.cont...@gmail.comwrote:
On Apr 15, 3:26 pm, "Angus" <nos...@gmail.comwrote:
Hello
I have a web page which uses a js file on the server. I cannot see all the
javascript functions available to me in the html. I would like to have a
function which could print eg to a DIV section, all the available functions.
Just the function names is fine.
Is there any way to do this in javascript?

TRY this:

function FuncList(DIV){
for(var funcs in window)
if(typeof(window[funcs])=="function"){
var tnode=document.createTextNode(funcs)
DIV.appendChild(tnode)
}

}

the above will print all the global functions.
I tried this:

for(var funcs in window)
{
var fnode=document.getElementById(DIV);
fnode.appendChild(document.createTextNode(funcs + ' '));
}
}

Output was:
onbeforeunload onafterprint top location parent
offscreenBuffering frameElement onerror screen event
clipboardData onresize defaultStatus onblur window onload
onscroll screenTop onfocus Option length onbeforeprint frames
self clientInformation external screenLeft opener onunload
document closed history Image navigator status onhelp name

But none of my javascript functions. I tried also for (var funcs in
document) but didn't give me what I wanted.

I need the list of javascript function names.

Apr 16 '07 #6
Angus wrote on 16 apr 2007 in comp.lang.javascript:
I tried this:
[..]

No that this helps you find userfunctions,
but perhaps someone can explain
this difference between window and document,
where appending with (document.f + ' ') gives undefined(!!!) [IE7]:

===========================
<div id=d><br></div>
<hr>
<div id=e><br></div>

<script type='text/javascript'>

function testttttttttttttttttt(){ alert(0); };

var d=document.getElementById('d');
for(var f in window)
d.appendChild(document.createTextNode(window.f + ' '));

var e=document.getElementById('e');
for(var f in document)
e.appendChild(document.createTextNode(window.f + ' '));

</script>
===========================

onbeforeunload onafterprint top location parent offscreenBuffering
frameElement onerror screen event clipboardData onresize defaultStatus
onblur window onload onscroll screenTop onfocus Option length
onbeforeprint frames self clientInformation XMLHttpRequest external
screenLeft opener onunload document closed history Image navigator status
onhelp name

-----------------------------------------------------

namespaces lastModified parentNode nodeType fileCreatedDate
onbeforeeditfocus bgColor oncontextmenu onrowexit embeds scripts
onactivate mimeType alinkColor onmousemove onselectstart oncontrolselect
body protocol onkeypress onrowenter onmousedown vlinkColor URL
onreadystatechange doctype onbeforedeactivate applets fileModifiedDate
onmouseover dir media defaultCharset firstChild plugins onafterupdate
ondragstart oncellchange cookie documentElement nextSibling nameProp
referrer ondatasetcomplete onmousewheel onerrorupdate onselectionchange
lastChild ondblclick onkeyup location forms title onrowsinserted
previousSibling compatMode onmouseup onkeydown onrowsdelete onfocusout
fgColor ondatasetchanged onmouseout parentWindow nodeName
onpropertychange onstop onhelp linkColor onbeforeactivate images
readyState frames all onbeforeupdate onclick childNodes onfocusin anchors
selection fileUpdatedDate domain security fileSize ownerDocument
ondataavailable styleSheets nodeValue attributes activeElement
implementation links URLUnencoded ondeactivate

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 16 '07 #7
On 16 Apr, 12:00, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
Angus wrote on 16 apr 2007 in comp.lang.javascript:
I tried this:

[..]

No that this helps you find userfunctions,
but perhaps someone can explain
this difference between window and document,
where appending with (document.f + ' ') gives undefined(!!!) [IE7]:

===========================
<div id=d><br></div>
<hr>
<div id=e><br></div>

<script type='text/javascript'>

function testttttttttttttttttt(){ alert(0); };

var d=document.getElementById('d');
for(var f in window)
d.appendChild(document.createTextNode(window.f + ' '));

var e=document.getElementById('e');
for(var f in document)
e.appendChild(document.createTextNode(window.f + ' '));

</script>
===========================

onbeforeunload onafterprint top location parent offscreenBuffering
frameElement onerror screen event clipboardData onresize defaultStatus
onblur window onload onscroll screenTop onfocus Option length
onbeforeprint frames self clientInformation XMLHttpRequest external
screenLeft opener onunload document closed history Image navigator status
onhelp name

-----------------------------------------------------

namespaces lastModified parentNode nodeType fileCreatedDate
onbeforeeditfocus bgColor oncontextmenu onrowexit embeds scripts
onactivate mimeType alinkColor onmousemove onselectstart oncontrolselect
body protocol onkeypress onrowenter onmousedown vlinkColor URL
onreadystatechange doctype onbeforedeactivate applets fileModifiedDate
onmouseover dir media defaultCharset firstChild plugins onafterupdate
ondragstart oncellchange cookie documentElement nextSibling nameProp
referrer ondatasetcomplete onmousewheel onerrorupdate onselectionchange
lastChild ondblclick onkeyup location forms title onrowsinserted
previousSibling compatMode onmouseup onkeydown onrowsdelete onfocusout
fgColor ondatasetchanged onmouseout parentWindow nodeName
onpropertychange onstop onhelp linkColor onbeforeactivate images
readyState frames all onbeforeupdate onclick childNodes onfocusin anchors
selection fileUpdatedDate domain security fileSize ownerDocument
ondataavailable styleSheets nodeValue attributes activeElement
implementation links URLUnencoded ondeactivate

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Yes, why no testttttttttttttttttt() in the list?

Apr 16 '07 #8

"Angus" <an*********@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
<cut>
Yes, why no testttttttttttttttttt() in the list?
It does work in Firefox, so perhaps IE just doesn't add the user functions
to the same [window] object we expect...

btw, havn't got IE7 handy right now but have you tried:

d.appendChild(document.createTextNode(window.f + '\u00A0'));


Apr 16 '07 #9

"Marc" <so******@dirtymail.comwrote in message
news:46*********************@news.xs4all.nl...
>
"Angus" <an*********@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
<cut>
>Yes, why no testttttttttttttttttt() in the list?

It does work in Firefox, so perhaps IE just doesn't add the user functions
to the same [window] object we expect...

btw, havn't got IE7 handy right now but have you tried:

d.appendChild(document.createTextNode(window.f + '\u00A0'));

It gets stranger and stranger... check the differences between FF and IE

<div id=d><br></div>
<hr>
<div id=e><br></div>
<script type='text/javascript'>

function testttttttttttttttttt(){ alert(0); };

var d=document.getElementById('d');
for(var f in window)
d.appendChild(document.createTextNode(window.f + ' '));

var e=document.getElementById('e');
for(var f in document)
e.appendChild(document.createTextNode(window.f + ' '));
// the window object exposes the document enumerations?
</script>
Apr 16 '07 #10
Marc wrote on 16 apr 2007 in comp.lang.javascript:
It gets stranger and stranger... check the differences between FF and IE
This works in IE7,
[FF does not recognize document.scripts]
and is the best I can do for the OP:

================================================== =====
<div id=e><br></div>

<script type='text/javascript' id=firstScript>
function testttttttttttttttttt(){ alert(0); };
function brrrrrrrrrrrrr(){ alert(0); };

</script>
<script type='text/javascript'>

var z = ''
for(var f=0;f<document.scripts.length;f++ ){
z += '\n==========================\n'
+ document.scripts[f].innerHTML
}
document.getElementById('e').innerText = z

</script>
================================================== ======

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 16 '07 #11
On 16 Apr, 15:05, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
Marc wrote on 16 apr 2007 in comp.lang.javascript:
It gets stranger and stranger... check the differences between FF and IE

This works in IE7,
[FF does not recognize document.scripts]
and is the best I can do for the OP:

================================================== =====
<div id=e><br></div>

<script type='text/javascript' id=firstScript>
function testttttttttttttttttt(){ alert(0); };
function brrrrrrrrrrrrr(){ alert(0); };

</script>
<script type='text/javascript'>

var z = ''
for(var f=0;f<document.scripts.length;f++ ){
z += '\n==========================\n'
+ document.scripts[f].innerHTML}

document.getElementById('e').innerText = z

</script>
================================================== ======

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
That is good. I must say.... But.

It doesn't display the function defined in a .js file on the server.
Or at least in my IE6 it doesn't.

I would like to be able to view ALL the javascript functions.

There is a product called debugbar - www.debugbar.com which can
achieve this. It is an Internet Explorer BHO. Not sure how they do
it but they can. So there must be a way.

Angus

Apr 16 '07 #12
Angus said the following on 4/16/2007 12:15 PM:

<snip>
There is a product called debugbar - www.debugbar.com which can
achieve this. It is an Internet Explorer BHO. Not sure how they do
it but they can. So there must be a way.
Not from within a webpage. A plugin has a lot more leeway than a webpage
does.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 16 '07 #13

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

Similar topics

12
by: Mary Catherine | last post by:
I have 2 scipts that I am trying to get to run on the same page. One is a time/date script, the other is a countdown script (i.e. countdown days, hours, mins until a given date). They both work...
4
by: Phillip N Rounds | last post by:
I need to eumerate all available drives in a C# Windows Form application ( and then of course the directory tree, but that's not the problem) My question is, how to I enumerate all the available...
7
by: localhost | last post by:
What is the best and/or fastest way to enumerate attributes of an HTML control? In my page template, I have: <body id="myBody" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"...
1
by: Tales Normando | last post by:
Hi, Can .NET enumerate all available IP addresses on a local network or do I have to resort to Windows API? How? Tales Normando
0
by: TheSilverHammer | last post by:
I am trying to figure out how to enumerate through registry keys and values using WMI and C#. Please, NO VB or VB.SCRIPTS. I have found plenty of examples of how to do this in VB and VBS. I...
21
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility...
3
by: ssghill | last post by:
Okay all i'm new to the asp portion but fairly good with vbscript. My problem is that I am trying to us an asp page to enumerate an ou. The problem is when I us localhoston the intranet web...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.