<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
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
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 ?
> 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.
_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.
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 :)
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.
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.
_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.
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..
I would be mightily interested in that article, though I don't believe they have
taken this approach.
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.
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.