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

Navigator object : how do I get all the inside elements?

Hi all

I am trying to read all the navigator object elements

1. Using the navigator.length returns undefined, cant use for loop;

2.Using and array of known elements like
var a = Array("appCodeName","appName","appVersion");
I seem to miss something to get it combined like navigator.a[i]

Anyone can help me a bit? Thanks

--
Windows98 links to solutions http://jake98.no-ip.info
Replies in the same thread please
Regards Jake
Jul 23 '05 #1
13 1779
In article <n1*********************@hebe.telenet-ops.be>, me@home.com
enlightened us with...
Hi all

I am trying to read all the navigator object elements


Why?
It rarely does anything useful.

If you're trying to do browser detection, it's worthless.
If you're trying to do plugin detection, I believe there's a better way
for that, too, but I'd have to go look it up.

--
--
~kaeli~
Contrary to popular opinion, the plural of 'anecdote' is
not 'fact'.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Jake wrote:
Hi all

I am trying to read all the navigator object elements

1. Using the navigator.length returns undefined, cant use for loop;

2.Using and array of known elements like
var a = Array("appCodeName","appName","appVersion");
I seem to miss something to get it combined like navigator.a[i]

Anyone can help me a bit? Thanks


for (var prop in navigator) {
document.write(
prop + ' = ' + navigator[prop] +
' (' + typeof navigator[prop] + ')' +
'<br>'
);
}

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #3

Hi Grant Wagner,
for (var prop in navigator) {
document.write(
prop + ' = ' + navigator[prop] +
' (' + typeof navigator[prop] + ')' +
'<br>'
);
}


Thanks Grant works great
now I need to figure out when typeof returns object, which I know hides some values too :)
--
Windows98 links to solutions http://jake98.no-ip.info
Replies in the same thread please
Regards Jake
Jul 23 '05 #4

Hi kaeli,
Why?
It rarely does anything useful.

If you're trying to do browser detection, it's worthless.
If you're trying to do plugin detection, I believe there's a better way
for that, too, but I'd have to go look it up.


Thanks
Great help :)
--
Windows98 links to solutions http://jake98.no-ip.info
Replies in the same thread please
Regards Jake
Jul 23 '05 #5
Jake wrote:
Hi Grant Wagner,
for (var prop in navigator) {
document.write(
prop + ' = ' + navigator[prop] +
' (' + typeof navigator[prop] + ')' +
'<br>'
);
}


Thanks Grant works great
now I need to figure out when typeof returns object, which I know hides some values too :)


Modify the function to call itself recursively with "obj[prop]" if "typeof obj[prop] ==
'object'". Note that this is filled with all sorts of pitfalls. Lots of user agents generate
errors from simply trying to _test_ "typeof object[property]" for specific properties of
specific (usually host) objects.

For example: alert((new Image()).nodeType); works fine in Firefox 0.9, but: alert((new
Image()).textContent); throws an exception, even though "textContent" is a valid property for
the Image object. So any "for (... in ...)" display of Image properties needs to specifically
exclude "textContent" on Firefox 0.9 (and most likely other Gecko-based browsers).

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #6
Hi Grant Wagner,

Thanks for replying
As you may notice I am fairly new at javascript
although i have some background from other languages
I fully appreciate your help
You advised :
Modify the function to call itself recursively with "obj[prop]" if "typeof obj[prop] ==
'object'". Note that this is filled with all sorts of pitfalls. Lots of user agents generate
errors from simply trying to _test_ "typeof object[property]" for specific properties of
specific (usually host) objects.


And this is what I brew of it :)

<HEAD>
<script language="javascript">
function show(p) {
document.write('parm = ' + p + '<br>');
for (i in p) {
document.write(
i +' : '
+' ('
+ typeof p[i]
+ ') '
+ p[i] );
if (typeof p[i] == 'object') {
// show(p[i]);
}
document.write('<br>');
}
}
</script>
</head>

<body>
<script language="javascript">
// document.write(navigator.plugins.length);
show(navigator);
</script>
</body>

A few questions:
1. first line in function, to debug should display the calling parameter? says parm = without a value, crlf is executed
2. when i uncomment the recursive line caller i get a second parm = , so the function calls itself, and stops
the error is object doesnt support this property or method
2a. how can i know programmatically what is supported?
2b. is there some sort of error trap so the rest of the function can continue to display the (working) rest?
3. Is it possible to bump the array into a new array with numeric indexes?
If so, the .length of each item would be available which would make things easier
Again, thanks for your time and effort.
--
Windows98 links to solutions http://jake98.no-ip.info
Replies in the same thread please
Best Regards
Jake
Jul 23 '05 #7
In article <4Z*********************@hestia.telenet-ops.be>,
"Jake" <me@home.com> wrote:

A few questions:
1. first line in function, to debug should display the calling parameter?
says parm = without a value, crlf is executed
2. when i uncomment the recursive line caller i get a second parm = , so the
function calls itself, and stops
the error is object doesnt support this property or method
2a. how can i know programmatically what is supported?
2b. is there some sort of error trap so the rest of the function can continue
to display the (working) rest?
3. Is it possible to bump the array into a new array with numeric indexes?
If so, the .length of each item would be available which would make things
easier
Again, thanks for your time and effort.


Thanks Jake I made a few additions to your code. See that addition of
var before the i. Without the var, i is a global variable. ( I left
out the var i in my object debug routine once too. )

For some reason, IE managed to come up with an error in for (var i in p)
when I did this. Do not know how. I added the try statement. I assume
this was causing the problem, but I now think it was the var i.

I know the differences in style. I copied some stuff.

I tired this in IE 5.2 for MacOS. I didn't try the posted version in
Netscape 7.1, but an earlier version took forever to run.

Robert

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<HEAD>
<script type="text/javascript">
function show(p) {
document.write('<br>parm = ' + p + '<br>');
for (var i in p) {

try
{
document.write(
"&nbsp;&nbsp;"
+ i +' : '
+' ('
+ typeof p[i]
+ ') '
+ p[i] );
}
catch(e)
{
document.write("... Error writing out structure. Was " +
p + " of " + i);
}

if (typeof p[i] == 'object') {
show(p[i]);
}
else {
document.write('<br>');
}
}

}
</script>
</head>

<body>
<script type="text/javascript">
// document.write(navigator.plugins.length);
show(navigator);
document.write("<br>Show the document<br>");
show(document);
</script>
</body>
Jul 23 '05 #8

Hi Robert,

A few questions:
1. first line in function, to debug should display the calling parameter?
says parm = without a value, crlf is executed
2. when i uncomment the recursive line caller i get a second parm = , so the
function calls itself, and stops
the error is object doesnt support this property or method
2a. how can i know programmatically what is supported?
2b. is there some sort of error trap so the rest of the function can continue
to display the (working) rest?
3. Is it possible to bump the array into a new array with numeric indexes?
If so, the .length of each item would be available which would make things
easier
Again, thanks for your time and effort.


Thanks Jake I made a few additions to your code. See that addition of
var before the i. Without the var, i is a global variable. ( I left
out the var i in my object debug routine once too. )

For some reason, IE managed to come up with an error in for (var i in p)
when I did this. Do not know how. I added the try statement. I assume
this was causing the problem, but I now think it was the var i.

I know the differences in style. I copied some stuff.

I tired this in IE 5.2 for MacOS. I didn't try the posted version in
Netscape 7.1, but an earlier version took forever to run.

Robert

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<HEAD>
<script type="text/javascript">
function show(p) {
document.write('<br>parm = ' + p + '<br>');
for (var i in p) {

try
{
document.write(
"&nbsp;&nbsp;"
+ i +' : '
+' ('
+ typeof p[i]
+ ') '
+ p[i] );
}
catch(e)
{
document.write("... Error writing out structure. Was " +
p + " of " + i);
}

if (typeof p[i] == 'object') {
show(p[i]);
}
else {
document.write('<br>');
}
}

}
</script>
</head>

<body>
<script type="text/javascript">
// document.write(navigator.plugins.length);
show(navigator);
document.write("<br>Show the document<br>");
show(document);
</script>
</body>


I have added you suggestion to the script and
The results:

with show(document) aborts because not enough memory
I can understand that since document contains a bunch of properties

with show(navigator) I still have the same error 'object does not support this type of property'

The questions at top still remain
Thanks for your effort
--
Replies in the same thread please
Windows 98 links to solutions
http://jake98.no-ip.info
Best Regards
Jake
Jul 23 '05 #9
In article <%q**********************@hestia.telenet-ops.be>,
"Jake" <me@home.com> wrote:
I have added you suggestion to the script and
The results:

with show(document) aborts because not enough memory
I can understand that since document contains a bunch of properties

with show(navigator) I still have the same error 'object does not support
this type of property'

The questions at top still remain
Thanks for your effort


I may have missed this info, what Operating System and what version of
the Operating System are you using? What web browser and version of the
web browser are you using?

Do you know what line of code is failing?

Robert
Jul 23 '05 #10

Hi Robert,
I may have missed this info, what Operating System and what version of
the Operating System are you using? What web browser and version of the
web browser are you using?
IE 6.0.2800.1106
Windows 98 Second Edition 4.10.2222 A

Do you know what line of code is failing?


Navigator typeof object = not supported

Thanks Robert

--
Replies in the same thread please
Windows 98 links to solutions
http://jake98.no-ip.info
Best Regards
Jake
Jul 23 '05 #11
Jake wrote:
<snip>
Do you know what line of code is failing?


Navigator typeof object = not supported


Either that isn't a line of code at all, or it is so generally erroneous
that it should be expected to fail.

Richard.
Jul 23 '05 #12
Hi Richard,

This thread has been going for a while, so here is the function
It gets stuck when the function accesses typeof navigator.plugins

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<HEAD>
<script type="text/javascript">
function show(p) {
document.write('<br>parm = ' + p + '<br>');
for (var i in p) {

try
{
document.write(
"&nbsp;&nbsp;"
+ i +' : '
+' ('
+ typeof p[i]
+ ') '
+ p[i] );
}
catch(e)
{
document.write("... Error writing out structure. Was " +
p + " of " + i);
}

if (typeof p[i] == 'object') {
show(p[i]);
}
else {
document.write('<br>');
}
}

}
</script>
</head>

<body>
<script type="text/javascript">
// document.write(navigator.plugins.length);
show(navigator);
document.write("<br>Show the document<br>");
show(document);
</script>
</body>

--
Replies in the same thread please
Windows 98 links to solutions
http://jake98.no-ip.info
Best Regards
Jake
Jul 23 '05 #13
"Jake" <me@home.com> wrote in message news:<NN********************@hebe.telenet-ops.be>...
Hi Richard,

This thread has been going for a while, so here is the function
It gets stuck when the function accesses typeof navigator.plugins


For some reason in the Winodows 98 version of IE, the statement for
(var i in p) is generating invalid values in variable i. Do not know
the story. I have coded up a workaround.

For testing javascript programs, I recommend using a Gecko based
browser like Netscape 7.1.

Example code follows.

I have not tried all the error paths.

Robert
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<HEAD>
<script type="text/javascript">
function show(p) {
document.write('<br>parm = ' + p + '<br>');
document.write('typeof p = ' + typeof p + '<br>');
if (typeof p == 'object' ) {
try {
for (var i in p) {
try {
document.write(
"&nbsp;&nbsp;"
+ i +' : '
+' ('
+ typeof p[i]
+ ') '
+ p[i] );
}
catch(e) {
document.write("... Error writing out structure. Was " +
p + " of " + i);
}

if (typeof p[i] == 'object') {
document.write("<br>[] i = " + i);
show(p[i]);
}
else {
document.write('<br>');
}
} // of for loop
} // of try for for statement
catch(e) {
document.write("<br>... for loop control problem. IE seems " +
"prone to these problems. e = " + e + "<br>");
}
} // of is object if
else {
document.write("... Error. Function expects an object " +
"but didn't get an object.");
document.write('typeof p = ' + typeof p + '<br>');
}

} // of function
</script>
</head>

<body>
<script type="text/javascript">
// document.write(navigator.plugins.length);
show(navigator);
//document.write("<br><br><br>Show the document<br>");
// show(document);
</script>
</body>
Jul 23 '05 #14

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

Similar topics

3
by: Phil Powell | last post by:
if (is_array($_POST)) { foreach ($this->getAssocSectionsObjArray($key, $dbAP) as $obj) { print_r($obj); print_r(" in array? "); print_r(in_array($obj, $result)); print_r("<P>"); if...
2
by: Lüpher Cypher | last post by:
Ok, here's what I'm trying to do. I have a class. Inside the class I have a method that reads a text file. In the text file I have a class name and a file name where that class is defined. Now, I...
4
by: Arjen | last post by:
Hi, I have a class with some attributes. For example class person with name as attribute. I have add multiple persons in an arraylist. Now I need a function to get/find a person by the name...
6
by: Rufnex | last post by:
Hi, is there a delete for a object inside the constructor, while i init it? i will try something like that: var obj = function(a) { if (!a) delete this; this.a = a; }
8
by: Alexander Walker | last post by:
Hello I am using a Dictionary to store some queues which store instances of a class that I have written I would like to be able to determine whether a particular queue already contains an...
2
by: Daz | last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best to word it. What I would like to know, is if there is an equivilant to this code, in using JSON. <script...
2
by: alchemist | last post by:
Hi everyone. I have a problem about object construction. I have two classes called Flight and ReservationSystem and have a function addFlight() which creates a Flight object and adds it to an array...
11
by: hash4sp | last post by:
Hello ! How do i assign tabindex to an object (listbox) that is generated dynamically inside an Iframe. I used the following code onload event of body, but it didnt work. Any suggestions would be...
1
by: JanetteM | last post by:
Need a line of code using the Navigator object to return the Web browser name to a variable called myBrowserName.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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...

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.