473,396 Members | 1,872 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.

Obtaining a list of an obect's methods.

Daz
Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.

Also, as I am learning, it would be nice to be able to know what
methods are available for a particular object/function, without
necessarily having to spend a while looking up an object's method when
it's documented in a lot of different places, but only vaguely.

Many thanks.

Daz.

Dec 6 '06 #1
8 1719
VK

Daz wrote:
Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.
what object on what UA has getObject() method? I'm not aware of any.
<html>
<head>
<title>Object properties</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<div>
<script type="text/javascript">

// change window on any other object
// you want to study:
var myObject = window;

var prop = new Array;
for (var p in myObject) {
prop.push(p);
}
prop.sort();
for (var i=0; i<prop.length; ++i) {
document.writeln(prop[i] + ' = ' + myObject[prop[i]] + '<br>');
}
</script>
</div>
</body>
</html>

Dec 6 '06 #2
Daz

VK wrote:
Daz wrote:
Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.

what object on what UA has getObject() method? I'm not aware of any.
<html>
<head>
<title>Object properties</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<div>
<script type="text/javascript">

// change window on any other object
// you want to study:
var myObject = window;

var prop = new Array;
for (var p in myObject) {
prop.push(p);
}
prop.sort();
for (var i=0; i<prop.length; ++i) {
document.writeln(prop[i] + ' = ' + myObject[prop[i]] + '<br>');
}
</script>
</div>
</body>
</html>
Thanks for that VK. That will come in very useful, although
unfortunately it doesn't work with getBrowser(). The problem is most
likely that I am not using getBrowser in the correct context, as I
don't know what it's a method of. I have thried Browser, BrowserObj,
window, and document, none of which seem to work.

I am trying to create an extension for Firefox and perhaps I am getting
confused between the standard JavaScript and the functions built-in to
Firefox.

Dec 6 '06 #3
Daz wrote:
The object I have in mind is getBrowser()
That's not an object, it's a function call.
And not a standard browser function, either.
Which means you're using some library, and we can't help unless we know what
library you're using.

Further, the getBrowser() function name leads me to believe that you're
doing some browser sniffing, which is not a good sign...
and I can't seem to find any documentation
online with regards to it's methods.
Well, where did you get it from? :)
Also, as I am learning, it would be nice to be able to know what
methods are available for a particular object/function, without
necessarily having to spend a while looking up an object's method when
it's documented in a lot of different places, but only vaguely.
Links at http://www.javascripttoolbox.com/resources/ should be extremely
helpful.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Dec 6 '06 #4

Daz wrote:
Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.
Google is your friend, is this what you are looking for?

<URL: http://www.xj3d.org/javadoc/vrml/eai...erFactory.html >

Note that is a Java function, which is very different to javascript.
This thread may be useful too:

<URL:
http://www.web3d.org/x3d/publiclists.../msg00004.html
>
Also, as I am learning, it would be nice to be able to know what
methods are available for a particular object/function, without
necessarily having to spend a while looking up an object's method when
it's documented in a lot of different places, but only vaguely.
In javascript, you can use for..in to get the enumerable properties of
an object. Whenever you call a function on its own it is likely that
you are calling it as a method of the window object, but you need to
understand the scope chain when the function is called to know that.

You can also use hasOwnProperty to determine if a method is a property
of the object itself or is inherited from its prototype chain.

However, simply getting an object's properties and then guessing how to
use them is not a sound way to program - how will you know what
arguments to pass, or how they are used? Use the FAQ to get a list of
on-line references, including those for JavaScript, JScript and various
DOM standards and implementations.

<URL: http://www.jibbering.com/faq/#FAQ3 >

--
Rob

Dec 6 '06 #5
Daz
Hi ROb, thanks for the reply.

RobG wrote:
Daz wrote:
Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.

Google is your friend, is this what you are looking for?

<URL: http://www.xj3d.org/javadoc/vrml/eai...erFactory.html >

Note that is a Java function, which is very different to javascript.
This thread may be useful too:

<URL:
http://www.web3d.org/x3d/publiclists.../msg00004.html
Unfortunately, neither of those URLs were useful with regards to
finding the methods of the getBrowser object. I think it's just one of
those things that's not very well documented.

RobG wrote:
However, simply getting an object's properties and then guessing how to
use them is not a sound way to program -
Agreed!
RobG wrote:
how will you know what
arguments to pass, or how they are used?
I don't. I will then know what methods are available, and then
hopefully be able to go and look them up with more success. Also, it's
a way of learning, and happens to be one of my preferred methods.
Rather than struggling to find a a method that I don't know exists, I
prefer to be able to read about various methods in my own time, and
often, when I need it most, I have at least a vague idea of what I
might need to use, so it's then just a case of looking up the syntax.
Most method names are quite descripitive, although not all of them.

The way I see it, is it's a bit like trying to memorize the chapter
names in a book, as opposed to trying to remember the chapters names
and the text from each chapter. I hope this makes sense to you.
RobG wrote:
Use the FAQ to get a list of
on-line references, including those for JavaScript, JScript and various
DOM standards and implementations.

<URL: http://www.jibbering.com/faq/#FAQ3 >
Now that's going to come in handy, although again, some what I am doing
is only really borderline JavaScript. It's JavaScript based, but not
necessarily part of the JavaScript core. I believe that getBrowser is a
JavaScript function that is native to Mozilla/Firefox, but I am not
100% on that.

Thanks again for your help.

Daz.

Dec 10 '06 #6
VK
Daz wrote:
I believe that getBrowser is a
JavaScript function that is native to Mozilla/Firefox, but I am not
100% on that.
OK, this hint broke the circle, though the question was *really*
cryptic.
It would be much more helpful to read something like: "at URL ... I
have found a mention of getBrowser used for ... What is it and where is
it?".

////////////

There is not native getBrowser object in JavaScript client-side
scripting. Thus any researches of it are even more futile than the
search of the Holly Grail :-)

Nevertheless:

Firefox 2.0 makes the first big step in implementing client-side
session data storage which IE users are enjoying with since 5.0
<http://msdn.microsoft.com/workshop/author/behaviors/reference/behaviors/userdata.asp>

In the particular Firefox 2.0 implements XPCOM session store API over
nsISessionStore interface. One of methods available over this interface
is getBrowserState() method
<http://developer.mozilla.org/en/docs/nsISessionStore#getBrowserState.28.29>

At <http://developer.mozilla.org/en/docs/Session_restore_APIit is
referred by mistake as getBrowser() method (the author must be got
confused with GetBrowser from BrowserHawk).

Overall the code snippets from
<http://developer.mozilla.org/en/docs/Session_restore_APIare getting
my prize by the amount of errors per line of code. That is atop of the
fact that the quality of samples for XPCOM / netscape.security matters
is awful both for MDC and XULPlanet. It is so thoroughly insistently
perpetually awful that I can explain it only by:

1) all writing goes under intoxication.
2) no one (including Gecko developers themselves) has a clue on the
matters.
3) until the relevant technologies are tested and interfaces are frozen
- until then an "allowance encryption" is used. Thus if someone knows
the matter she will be able to correct the code in the needed way so
use it for testing. Anyone else will fail to use the code so she will
give up for now.

Needless to say that I believe and hope that the most favorable to
Mozilla option (the third one) is the real true.

I myself once had to work extensively with Netscape Capabilities APIs
for JVM and the involved matters. This way now I'm in the position of
Cicero listening some drunk Roman legionnaire from a far province :-) -
with some efforts made I can understand what a hey is he talking about
and write down his speech with the proper words and in the proper
grammatical forms.

Sorry for blah-blah, anyway...

So there is nsISessionStore interface, and this interface implements
getBrowserState method. There is no "getBrowser" method in it: that is
a phantasm of a MDC participant.

nsISessionStore interface is accessible over XPCOM interface for
Firefox 2.0 or higher. XPCOM interface is not accessible until the
needed privilege is granted to the browser. This way the restored code
is:

!!! Important: Google News corrupts strings on display if they contain
@ (at-sign). Because XPCOM call contains at-sign, this code will be
corrupted and not working if copied from your browser window. After
copy and past first locate the string
Components.classes['
and remove dotes (ellipsis) right after the single quote.

<html>
<head>
<title>getBrowserState</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body onload="
/* Firefox 2.0 or higher.
* Security restrictions are applied
* (cannot be run within the default sandbox).
*/
netscape.security.PrivilegeManager.
enablePrivilege('UniversalXPConnect');
var s = Components.classes['@mozilla.org/browser/sessionstore;1'].
getService(Components.interfaces.nsISessionStore);
s.init(self);
window.alert(s.getBrowserState());
">
</body>
</html>
P.S. No, I will not jump on correcting relevant sections on XULPlanet
or MDC - though anyone is welcome to replace the current nonsense at
<http://developer.mozilla.org/en/docs/Session_restore_APIwith the
posted sample.
First of all, IMHO it's like emptying an ocean with a bucket. Secondly
and most importantly I do not agree with the MDC concept of "OK, guys,
we've programmed some cool stuff, you tell us what is it doing". Excuse
me: it is not an end-users' task to document "black boxes" over
try-fail-success cycles. Each programmer has to place an fn initial
document clearly stating what the hay is done, how in the name is it
done, what the fricking arguments are required, what the hell methods
are supported. That can be a plain text file or a scan image copy of a
sticker from his desktop: *anything* to start with. Then we can test
it, report bugs, "put the flash" of nicer wording and samples.
That seems not only my opinion, but a background feeling of many other
people: at least from one year to another MDC fails to be as helpful as
expected for advanced Gecko features.

Dec 11 '06 #7
Daz

VK wrote:
Daz wrote:
I believe that getBrowser is a
JavaScript function that is native to Mozilla/Firefox, but I am not
100% on that.

OK, this hint broke the circle, though the question was *really*
cryptic.
It would be much more helpful to read something like: "at URL ... I
have found a mention of getBrowser used for ... What is it and where is
it?".

////////////

There is not native getBrowser object in JavaScript client-side
scripting. Thus any researches of it are even more futile than the
search of the Holly Grail :-)

Nevertheless:

Firefox 2.0 makes the first big step in implementing client-side
session data storage which IE users are enjoying with since 5.0
<http://msdn.microsoft.com/workshop/author/behaviors/reference/behaviors/userdata.asp>

In the particular Firefox 2.0 implements XPCOM session store API over
nsISessionStore interface. One of methods available over this interface
is getBrowserState() method
<http://developer.mozilla.org/en/docs/nsISessionStore#getBrowserState.28.29>

At <http://developer.mozilla.org/en/docs/Session_restore_APIit is
referred by mistake as getBrowser() method (the author must be got
confused with GetBrowser from BrowserHawk).

Overall the code snippets from
<http://developer.mozilla.org/en/docs/Session_restore_APIare getting
my prize by the amount of errors per line of code. That is atop of the
fact that the quality of samples for XPCOM / netscape.security matters
is awful both for MDC and XULPlanet. It is so thoroughly insistently
perpetually awful that I can explain it only by:

1) all writing goes under intoxication.
2) no one (including Gecko developers themselves) has a clue on the
matters.
3) until the relevant technologies are tested and interfaces are frozen
- until then an "allowance encryption" is used. Thus if someone knows
the matter she will be able to correct the code in the needed way so
use it for testing. Anyone else will fail to use the code so she will
give up for now.

Needless to say that I believe and hope that the most favorable to
Mozilla option (the third one) is the real true.

I myself once had to work extensively with Netscape Capabilities APIs
for JVM and the involved matters. This way now I'm in the position of
Cicero listening some drunk Roman legionnaire from a far province :-) -
with some efforts made I can understand what a hey is he talking about
and write down his speech with the proper words and in the proper
grammatical forms.

Sorry for blah-blah, anyway...

So there is nsISessionStore interface, and this interface implements
getBrowserState method. There is no "getBrowser" method in it: that is
a phantasm of a MDC participant.

nsISessionStore interface is accessible over XPCOM interface for
Firefox 2.0 or higher. XPCOM interface is not accessible until the
needed privilege is granted to the browser. This way the restored code
is:

!!! Important: Google News corrupts strings on display if they contain
@ (at-sign). Because XPCOM call contains at-sign, this code will be
corrupted and not working if copied from your browser window. After
copy and past first locate the string
Components.classes['
and remove dotes (ellipsis) right after the single quote.

<html>
<head>
<title>getBrowserState</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body onload="
/* Firefox 2.0 or higher.
* Security restrictions are applied
* (cannot be run within the default sandbox).
*/
netscape.security.PrivilegeManager.
enablePrivilege('UniversalXPConnect');
var s = Components.classes['@mozilla.org/browser/sessionstore;1'].
getService(Components.interfaces.nsISessionStore);
s.init(self);
window.alert(s.getBrowserState());
">
</body>
</html>
P.S. No, I will not jump on correcting relevant sections on XULPlanet
or MDC - though anyone is welcome to replace the current nonsense at
<http://developer.mozilla.org/en/docs/Session_restore_APIwith the
posted sample.
First of all, IMHO it's like emptying an ocean with a bucket. Secondly
and most importantly I do not agree with the MDC concept of "OK, guys,
we've programmed some cool stuff, you tell us what is it doing". Excuse
me: it is not an end-users' task to document "black boxes" over
try-fail-success cycles. Each programmer has to place an fn initial
document clearly stating what the hay is done, how in the name is it
done, what the fricking arguments are required, what the hell methods
are supported. That can be a plain text file or a scan image copy of a
sticker from his desktop: *anything* to start with. Then we can test
it, report bugs, "put the flash" of nicer wording and samples.
That seems not only my opinion, but a background feeling of many other
people: at least from one year to another MDC fails to be as helpful as
expected for advanced Gecko features.
Many thanks for your input. You make some very interesting points, most
of which I happen to agree with. No worries about the 'blah-blah'. I
enjoy reading what others have to say, especially when I have the
opportunity to learn from it, as well as increasing my understanding of
the subject and possibly changing my opinions which could have been
made without the correct information.

Thanks again.

Daz.

Dec 11 '06 #8
Here is another aimed at ecmascript.

some descriptions will include an abstract

<http://www.web3d.org/x3d/specifications/ISO-IEC-19775-X3DAbstractSpecification/Part02/servRef.html#getBrowser>

then follow up with details for a specific implementation

<http://www.web3d.org/x3d/specifications/ISO-IEC-19777-1-X3DLanguageBindings-ECMAScript/Part1/functions.html#t-FunctionsBrowserObject>

The idea behind an object like getBrowser is that an
application 'external' to the embedded 'Browser' object
is asking for the embedded object to expose its content.
For example, a scriptable object like X3D, SVG, Flash,
WMP, etc is embedded in a host DOM and the author wishes
to control and respond to events of the embedded content.

At the first level of control, such as when using an html/xhtml
object node as the container, Properties of the 'Browser' object
are probably exposed as param name-value pairs and
you won't need getBrowser.

When you need Functions of the Browser object to create,
replace, and set up event interfaces between the
container and containee, so as to operate in the guts of
the embedded content, then you need getBrowser.

Needless to say this is a great application area because
there are so many neat plug-ins out there, if you can
get them past user/browser security. A typical application
development path with a capable plug-in might be one in which
more and more of the application functionality is moved from the
'external' host scripting to the 'internal' scripting capabiitities of the
plug-in. if you are lucky, then your logic and basic coding works
as just simply transfer the script to inside the plug-in, ditching the
getBrowser and event passing rigs.

Good Luck,
Joe

"RobG" <rg***@iinet.net.auwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
>
Daz wrote:
>Hi everyone.

I just wanted to know if there was any way to use script to display a
list of methods linked to a particular object? The object I have in
mind is getBrowser(), and I can't seem to find any documentation online
with regards to it's methods.

Google is your friend, is this what you are looking for?

<URL: http://www.xj3d.org/javadoc/vrml/eai...erFactory.html >

Here is another aimed at ecmascript.

Some descriptions will include an abstract

<http://www.web3d.org/x3d/specifications/ISO-IEC-19775-X3DAbstractSpecification/Part02/servRef.html#getBrowser>

then follow up with details for a specific implementation

<http://www.web3d.org/x3d/specifications/ISO-IEC-19777-1-X3DLanguageBindings-ECMAScript/Part1/functions.html#t-FunctionsBrowserObject>

The idea behind an object like getBrowser is that an
application 'external' to the embedded 'Browser' object
is asking for the embedded object to expose its content.
For example, a scriptable object like X3D, SVG, Flash,
WMP, etc is embedded in a host DOM and the author wishes
to control and respond to events of the embedded content.

At the first level of control, such as when using an html/xhtml
object node as the container, Properties of the 'Browser' object
are probably exposed as param name-value pairs and
you won't need getBrowser.

When you need Functions of the Browser object to create,
replace, and set up event interfaces between the
container and containee, so as to operate in the guts of
the embedded content, then you need getBrowser.

Needless to say this is a great application area because
there are so many neat plug-ins out there, if you can
get them past user/browser security. A typical application
development path with a capable plug-in might be one in which
more and more of the application functionality is moved from the
'external' host scripting to the 'internal' scripting capabiitities of the
plug-in. if you are lucky, then your logic and basic coding works
as just simply transfer the script to inside the plug-in, ditching the
getBrowser and event passing rigs.

Good Luck,
Joe
>
Note that is a Java function, which is very different to javascript.
This thread may be useful too:

<URL:
http://www.web3d.org/x3d/publiclists.../msg00004.html
>>
>Also, as I am learning, it would be nice to be able to know what
methods are available for a particular object/function, without
necessarily having to spend a while looking up an object's method when
it's documented in a lot of different places, but only vaguely.

In javascript, you can use for..in to get the enumerable properties of
an object. Whenever you call a function on its own it is likely that
you are calling it as a method of the window object, but you need to
understand the scope chain when the function is called to know that.

You can also use hasOwnProperty to determine if a method is a property
of the object itself or is inherited from its prototype chain.

However, simply getting an object's properties and then guessing how to
use them is not a sound way to program - how will you know what
arguments to pass, or how they are used? Use the FAQ to get a list of
on-line references, including those for JavaScript, JScript and various
DOM standards and implementations.

<URL: http://www.jibbering.com/faq/#FAQ3 >

--
Rob

Dec 15 '06 #9

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

Similar topics

6
by: Griff | last post by:
@array1 = (1,2,3); $length = @array1; # assigning a slice to $length print "length = $length"; # prints 3 (ie length of array not length of slice) @slice = @array1; print "\n";
7
by: Joseph Cook | last post by:
I was wondering if there was any way to do the following: If I have a class Base, and multiple Derived classes which all have some different behavior on some function foo()...is there any good...
5
by: Darryl B | last post by:
I can not get anywhere on this project I'm tryin to do. I'm not expecting any major help with this but any would be appreciated. The assignment is attached. The problem I'm having is trying to set...
1
by: Byrocat | last post by:
These particular servers do not have the DAS enabled, so I have to document the contents of the instances, initially "instance X contains n databases (A, B, C< ....)") I can get get list of...
11
by: John Nagle | last post by:
The Python SSL object offers two methods from obtaining the info from an SSL certificate, "server()" and "issuer()". The actual values in the certificate are a series of name/value pairs in ASN.1...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
1
by: kvcraju123 | last post by:
what is your toughest obect in oracle d2k
1
by: dmitrey | last post by:
hi all, howto check is function capable of obtaining **kwargs? i.e. I have some funcs like def myfunc(a,b,c,...):... some like def myfunc(a,b,c,...,*args):... some like
9
by: parent.eric.3 | last post by:
Hi, I would like to get the references to objets to put in a huge data structure (like a list or a heap for example). My objective is to use as less memory as possible as I have to manage huge...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.