Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

strange item property of window object

70 views
Skip to first unread message

Martin Honnen

unread,
Nov 7, 2001, 8:43:16 AM11/7/01
to
With IE6 when running

<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write('item: ' + item + '<br \/>');
document.write('item.constructor: ' + item + '<br \/>');
var r = '';
for (var property in item)
r += p + ': ' + item[property] + '<br \/>';
document.write('properties of item:<br \>' + r);
try {
item = 'Kibology';
}
catch (e) {
var r = '';
for (var p in e)
r += p + ': ' + e[p] + '<br \/>';
document.write('Error when assigning to item:<br \/> ' + r);
}
document.write('"item" in window: ' + ("item" in window));
</script>
</body>
</html>

I get the following results

item: [object]
item.constructor: [object]
properties of item:
Error when assigning to item:
name: TypeError
message: Das Objekt unterstützt diese Aktion nicht.
number: -2146827843
description: Das Objekt unterstützt diese Aktion nicht.
"item" in window: true

Error messages are in German on my system, should be something like
message: object doesn't support this action

What is this item object good for?

--

Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html

--

Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html

Thor Larholm

unread,
Nov 7, 2001, 8:54:10 AM11/7/01
to
"Martin Honnen" <Martin...@t-online.de> wrote in message
news:3BE93A74...@t-online.de...
> With IE6 when running
<snip>

> What is this item object good for?

I have no idea, and stumbled upon it much like you did, by trying to use it as a
variable name.

For reference sake, I am using IE5.5 SP2 and experience the same.

--
Thor Larholm
<URL: http://www.jibbering.com/faq/> FAQ for comp.lang.javascript


Thor Larholm

unread,
Nov 7, 2001, 9:10:09 AM11/7/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:#E0PuN5ZBHA.2148@tkmsftngp05...

> "Martin Honnen" <Martin...@t-online.de> wrote in message
> news:3BE93A74...@t-online.de...
> > What is this item object good for?

Good ol Object Viewer gives some more detail:

dispinterface DispHTMLWindow2
-Methods
--Item
---[id(00000000)]
---VARIANT item([in] VARIANT* pvarIndex);

under coclass HTMLWindow2, it also resides in IHTMLWindow2 with the same
information. Hence, it's been there from the beginning (Window2 is IE3+, afair).

"typeof item" returns "string"
"item.constructor" returns "function String(){ [native code] }"
and item contains the string "[object]"

Still, what use is it for ?

Jim Ley

unread,
Nov 7, 2001, 9:17:59 AM11/7/01
to

"Thor Larholm" <th...@jubii.dk> wrote in message
news:ernXvW5ZBHA.1732@tkmsftngp05...

> "Thor Larholm" <th...@jubii.dk> wrote in message
> news:#E0PuN5ZBHA.2148@tkmsftngp05...
> > "Martin Honnen" <Martin...@t-online.de> wrote in message
> > news:3BE93A74...@t-online.de...
> > > What is this item object good for?
>
> Good ol Object Viewer gives some more detail:
>
> dispinterface DispHTMLWindow2

> Still, what use is it for ?

IHTMLWindow2 has a _newEnum property returning an enumerator, could item
be related to this and for some reason its getting exposed to the script
enviroment aswell?

Jim.

Thor Larholm

unread,
Nov 7, 2001, 9:35:51 AM11/7/01
to
"Jim Ley" <j...@jibbering.com> wrote in message
news:us#Msc5ZBHA.1832@tkmsftngp04...

_newEnum is defined as

[id(0x00000481), propget, restricted, hidden]
IUnknown* _newEnum();

and item expects a VARIANT*, so I don't think they are related.

Typical, they hide the good stuff like navigator.connectionSpeed
([id(0x00000012), propget, hidden] long connectionSpeed();), but show the
irrelevant stuff.

Thor Larholm

unread,
Nov 7, 2001, 10:10:28 AM11/7/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:e$GqJl5ZBHA.1916@tkmsftngp05...

> "Jim Ley" <j...@jibbering.com> wrote in message
> > IHTMLWindow2 has a _newEnum property returning an enumerator, could item
> > be related to this and for some reason its getting exposed to the script
> > enviroment aswell?
> and item expects a VARIANT*, so I don't think they are related.

I take that back !

http://msdn.microsoft.com/library/en-us/vcug98/html/_asug_item_method.asp

It even works surprisingly well for me, getting references to other windows
through their captions:

Thor Larholm

unread,
Nov 7, 2001, 10:42:47 AM11/7/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:OezdX45ZBHA.1028@tkmsftngp04...

> "Thor Larholm" <th...@jubii.dk> wrote in message
> news:e$GqJl5ZBHA.1916@tkmsftngp05...
> > "Jim Ley" <j...@jibbering.com> wrote in message
> > > IHTMLWindow2 has a _newEnum property returning an enumerator, could item
> > > be related to this and for some reason its getting exposed to the script
> > > enviroment aswell?
> > and item expects a VARIANT*, so I don't think they are related.
>
> I take that back !
>
> http://msdn.microsoft.com/library/en-us/vcug98/html/_asug_item_method.asp
>
> It even works surprisingly well for me, getting references to other windows
> through their captions:

<iframe src="about:<html><body>LOOK</body></html>" id=HI></iframe>

alert(window.item("HI").document.body.innerHTML)

Strange, a minute ago I was able to get references to foreign window objects as
well - this needs a bit more experimenting :)

Peter Torr (MS)

unread,
Nov 7, 2001, 9:03:56 PM11/7/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:#E0PuN5ZBHA.2148@tkmsftngp05...

> I have no idea, and stumbled upon it much like you did, by trying to use
it as a
> variable name.

Hi,

If you declare the varaible with "var item" it should work.

It is only because you use it undeclared that you get IE's property.

Peter

--
Peter Torr -- pt...@microsoft.com -- JScript .NET / VSA Runtime
Waiting for the Vengabus? http://www.microsoft.com/info/cpyright.htm
Please post all questions to the group. Thanks.

Peter Torr (MS)

unread,
Nov 7, 2001, 9:08:23 PM11/7/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:e$GqJl5ZBHA.1916@tkmsftngp05...

> Typical, they hide the good stuff like navigator.connectionSpeed
> ([id(0x00000012), propget, hidden] long connectionSpeed();), but show the
> irrelevant stuff.

Just guessing, but that property may be inaccurate. How would they get the
value? No matter what method they used, it wouldn't be helpful because the
actual speed at which you connect has little to do with the speed at which
you get content (other than to put an absolute upper bound on it). Sure, it
would be helpful to know if the user had a 28k modem versus a T1, but you
couldn't make reasonable decisions based on the exact returned speed.

Peter Torr (MS)

unread,
Nov 7, 2001, 9:05:55 PM11/7/01
to
"Jim Ley" <j...@jibbering.com> wrote in message
news:us#Msc5ZBHA.1832@tkmsftngp04...

> IHTMLWindow2 has a _newEnum property returning an enumerator, could item
> be related to this and for some reason its getting exposed to the script
> enviroment aswell?

_NewEnum and Item have nothing in common, except convention.

_NewEnum returns an enumerator object, which basically lets you read items
off a collection sequentially (and skip items and start again at the
beginning). There is no way with an enumerator to get at a particular item
by index number. Item is used to index a collection by ordinal / key.

*Usually* if you have a collection, you want to index it and enumerate it,
so you often see Item and _NewEnum together, but they actually have nothing
to do with each other.

Thor Larholm

unread,
Nov 8, 2001, 1:57:17 AM11/8/01
to
"Peter Torr (MS)" <pt...@microsoft.com> wrote in message
news:uUtbI8$ZBHA.1440@tkmsftngp04...

> "Thor Larholm" <th...@jubii.dk> wrote in message
> news:e$GqJl5ZBHA.1916@tkmsftngp05...
> > Typical, they hide the good stuff like navigator.connectionSpeed
> > ([id(0x00000012), propget, hidden] long connectionSpeed();), but show the
> > irrelevant stuff.
>
> Just guessing, but that property may be inaccurate. How would they get the
> value? No matter what method they used, it wouldn't be helpful because the
> actual speed at which you connect has little to do with the speed at which
> you get content (other than to put an absolute upper bound on it). Sure, it
> would be helpful to know if the user had a 28k modem versus a T1, but you
> couldn't make reasonable decisions based on the exact returned speed.

Sure you could, WindowsUpdate does a fine job on it. It lists a very accurate
download time for me, which is awfully well adjusted to my connection speed
(tested on 9.6K, 56K, ADSL, T1). Now if only I could get to that same property..

Joe Fawcett

unread,
Nov 8, 2001, 3:01:05 AM11/8/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:eGAkeJCaBHA.1432@tkmsftngp02...
Not 100% sure but I don't think they do it like that. I seem to recall an
article on MS about it. They do it by monitoring how long it has taken to
download a known size. I'll see if I can find it.
Joe


Thor Larholm

unread,
Nov 8, 2001, 3:16:07 AM11/8/01
to
"Joe Fawcett" <j...@rightway.co.uk> wrote in message
news:e3aHVuCaBHA.1452@tkmsftngp03...

> "Thor Larholm" <th...@jubii.dk> wrote in message
> news:eGAkeJCaBHA.1432@tkmsftngp02...
<snip on WindowsUpdate>

> Not 100% sure but I don't think they do it like that. I seem to recall an
> article on MS about it. They do it by monitoring how long it has taken to
> download a known size. I'll see if I can find it.

I would be mightily interested in that article, though I don't believe they have
taken this approach.

Jim Ley

unread,
Nov 8, 2001, 6:58:37 AM11/8/01
to

"Peter Torr (MS)" <pt...@microsoft.com> wrote in message
news:uUtbI8$ZBHA.1440@tkmsftngp04...
> "Thor Larholm" <th...@jubii.dk> wrote in message
> news:e$GqJl5ZBHA.1916@tkmsftngp05...
> > Typical, they hide the good stuff like navigator.connectionSpeed
> > ([id(0x00000012), propget, hidden] long connectionSpeed();), but show
the
> > irrelevant stuff.
>
> Just guessing, but that property may be inaccurate. How would they get
the
> value? No matter what method they used, it wouldn't be helpful because
the
> actual speed at which you connect has little to do with the speed at
which
> you get content (other than to put an absolute upper bound on it).
Sure, it
> would be helpful to know if the user had a 28k modem versus a T1, but
you
> couldn't make reasonable decisions based on the exact returned speed.

In the VML/SMIL MS markup language there's the attribute about file size
(dependant content depending on file size) this is got (apparently) on a
site basis and calculated continously - this is pretty easy to do, you
just need to average time taken per KB, and the more data you download
the more accurate this will be. I still doubt its accuracy or even its
implementation - the documentation on it just says "not implemented".

Jim.

Peter Torr (MS)

unread,
Nov 8, 2001, 4:25:11 PM11/8/01
to
"Thor Larholm" <th...@jubii.dk> wrote in message
news:eGAkeJCaBHA.1432@tkmsftngp02...

> Sure you could, WindowsUpdate does a fine job on it. It lists a very
accurate
> download time for me, which is awfully well adjusted to my connection
speed
> (tested on 9.6K, 56K, ADSL, T1). Now if only I could get to that same
property..

Just because you are connected at, say, 100 MB doesn't mean that that's how
fast you get data. For a start, you could be connecting to a server that
only has a 56k modem link to the net. Another problem is that there is no
real QOS on the net at large. How often have you started a download of
something, had really good download speed, and then halfway through it slows
to a crawl?

I connect to the net via Microsoft's incredibly fast connection, but
sometimes it takes donkeys years for a simple page to download for whatever
reason.

Thor Larholm

unread,
Nov 9, 2001, 4:52:47 AM11/9/01
to
"Peter Torr (MS)" <pt...@microsoft.com> wrote in message
news:#9RYjvJaBHA.612@tkmsftngp03...

> Just because you are connected at, say, 100 MB doesn't mean that that's how
> fast you get data. For a start, you could be connecting to a server that
> only has a 56k modem link to the net. Another problem is that there is no
> real QOS on the net at large. How often have you started a download of
> something, had really good download speed, and then halfway through it slows
> to a crawl?
>
> I connect to the net via Microsoft's incredibly fast connection, but
> sometimes it takes donkeys years for a simple page to download for whatever
> reason.

I know all the caveats, pros and cons from relying on a predetermined connection
speed, but it would still be helpful to know that connection speed.

Ala, I have found other ways to solve the problem - our firewall makes a
qualified guess on the clients connection speed after a few TCP/IP packets which
so far proves very reliable.

0 new messages