473,396 Members | 1,921 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,396 software developers and data experts.

window.item/attributes

Hi guys,

Is there a way to retreave the javascript functions' names on the page?

The javascript functions are properties of the global object
(window/frame), but I do not know how to collect the functions' names.

Also, I notice that
windows.item
document.scripts.item

Is there a way to find what are the items' names?

Thanks

Nov 23 '05 #1
5 3180
zk*****@hotmail.com wrote:
Hi guys,

Is there a way to retreave the javascript functions' names on the page?
There is a lengthy discussion here:

<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/800641e55d59fb3a/bfab46faf88c7443?q=callee+caller&rnum=2#bfab46faf8 8c7443>


The javascript functions are properties of the global object
(window/frame), but I do not know how to collect the functions' names.

Also, I notice that
windows.item
document.scripts.item
A scripts collection has been implemented by some browsers but not by
all. Collections like links, images, etc. are part of DOM 0 and are
supported as 'legacy' components. Support for them will likely never be
dropped, but will probably never be extended as part of the
specification either.

The NodeList interface seems to be the generic replacement[1] so a more
reliable cross-browser method is to use:

document.getElementsByTagName('script').

Is there a way to find what are the items' names?


// Show function name
alert(arguments.callee.name);
1. Collections like images, links, forms, etc. should still be used
whenever appropriate as they are very widely supported and probably
faster than getElementsByTagName.

--
Rob
Nov 23 '05 #2
Thanks Rob.

Is there a way to get the collection of functions' names; like we get
the attributes for other objects; e.g. for a table cell with name of
"TD1", we can do
var objCell = document.all.TD1;

for (var i=0; i< objCell.attributes[0].length; i++)
{ alert(objCell.attributes[0].nodeName;}

Thank you.

Albion(052x)

Nov 23 '05 #3
Kevin Zhao wrote:
Thanks Rob.

Is there a way to get the collection of functions' names; like we get
the attributes for other objects; e.g. for a table cell with name of
"TD1", we can do
var objCell = document.all.TD1;

for (var i=0; i< objCell.attributes[0].length; i++)
{ alert(objCell.attributes[0].nodeName;}

Thank you.

Albion(052x)


There is no 'functions' collection. Collections are specified in the
DOM, functions are part of JavaScript. The difference between DOM and
JavaScript, or more correctly ECMAScript, is often not clearly understood.

When you declare a function like:

<script type="text/javascript">

function someFn() { };

</script>
Then a property with a name of 'someFn' is added to the global object
and its value is the content of the function. In a browser (HTML DOM)
environment, there is a window object that is, for all intents and
purposes, the global object. Or as section 10.1.5 of the ECMASpec says:

"...the window property of the global object is the global
object itself."

The window object has lots of properties, I'm not sure it is possible to
find all of the ones that were added by a script (though there might be).

Drop this into a page to see what's there:

<script type="text/javascript">

var prop,
wProps = [],
i=0;

for (prop in window){
wProps[wProps.length] = i++ + ' '
+ prop + ': ' + window[prop]
+ '<i>' + (typeof window[prop]) + '</i>'
;
}
document.write( wProps.join('<br>'));

</script>

There are also anonymous functions which may be harder to find.
--
Rob
Nov 23 '05 #4
RobG wrote:
zk*****@hotmail.com wrote:
windows.item
document.scripts.item
A scripts collection has been implemented by some browsers but not by
all.


ACK
Collections like links, images, etc. are part of DOM 0 and are
supported as 'legacy' components. Support for them will likely never be
dropped, but will probably never be extended as part of the
specification either.


Still not true. Those collections are attributes of the HTMLDocument
interface of the W3C DOM Level 2 HTML Specification which at least
partially implemented by browsers.

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268>
PointedEars
Nov 23 '05 #5
Thanks for replying.

Kevin Zhao

Nov 23 '05 #6

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

Similar topics

0
by: Stephen Carson | last post by:
I cannot see a browsable property I have added in the Properties Window. Using C++ in Visual Studio .NET 2003 I have added a property to my managed class: public:
5
by: REB | last post by:
Can someone help me with adding some javascript functionality to a button? What would the proper syntax for for (please help with the javascript I am rusty) for doing this: ...
0
by: ChrisB | last post by:
I'm attempting to open a new window from a LinkButton in a DataGrid. I can set a session variable in the ItemCommand event for the LinkButton like so: // this is used to handle the ItemCommand...
6
by: SkeanDu | last post by:
Ok, here is my problem. I have an aspx page that displays a databound datagrid and in one of the datagrid column headers I have an image that when clicked opens up a modal web dialog (another...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
2
by: GD | last post by:
I have an ImageButton in a Repeater, and in the Repeater's OnItemDataBound event, I'd like to add some code that will let the ImageButton open a URL in a new window. This is what I have in my...
1
by: settyv | last post by:
Hi, I need to open PDF document in new window when i click on linkbutton in datagrid.For that i have written code as below: But the problem with this code is that it opens the new window...
1
by: frickeme | last post by:
I have an asp page that uses javascript <textarea rows="2" cols="20" name="emailto" ID="Textarea2"><%=emailto%></textarea><input type="button"...
4
by: jrod11 | last post by:
I have an RSS reader that I have been using, but the only problem i have is that I want the target to be "_blank" rather than the parent window. Anyone know where I should add the _blank? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.