473,799 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.lengt h returns undefined, cant use for loop;

2.Using and array of known elements like
var a = Array("appCodeN ame","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 1817
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.lengt h returns undefined, cant use for loop;

2.Using and array of known elements like
var a = Array("appCodeN ame","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*****@agrico reunited.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()).nodeTy pe); works fine in Firefox 0.9, but: alert((new
Image()).textCo ntent); throws an exception, even though "textConten t" is a valid property for
the Image object. So any "for (... in ...)" display of Image properties needs to specifically
exclude "textConten t" on Firefox 0.9 (and most likely other Gecko-based browsers).

--
| Grant Wagner <gw*****@agrico reunited.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="javas cript">
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="javas cript">
// document.write( navigator.plugi ns.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 programmaticall y 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************ *********@hesti a.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 programmaticall y 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;&nbs p;"
+ 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.plugi ns.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 programmaticall y 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;&nbs p;"
+ 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.plugi ns.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************ **********@hest ia.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

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

Similar topics

3
10694
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 (!in_array($obj, $result)) array_push($result, $obj); } }
2
3061
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 need to instantiate an object of that class, the problem being that at the time I find out the class name and the file name, I'm inside a method of another class. Well, let me just type up a little example: class MainClass { $obj = null;
4
12999
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 attribute. This function returns the index or the object. I can do this with a foreach statement. I think there are better solutions,
6
2244
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
1881
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 instance with a particular value Here is the code
2
1513
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 type="text/javascript"> function makeTable(number_of_rows) { var table = document.createElement('table'); table.border = 1;
2
2366
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 inside ReservationSystem: <Code removed, by request of alchemist, by MODERATOR> when I call this inside main as R.addFlight(100,10,10); if prints Flight 100 successfully added,so creates the object and does everything but then displays...
11
5597
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 appreciated. parent.document.getElementById("CitiesFrame").contentWindow.document.getElementById("city").tabindex='1'; Thanks & regards, Hashmi
1
1616
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
9686
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9540
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10222
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10026
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.