By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Obtaining a list of an obect's methods.

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.