...

View Full Version : looping self/window



subhailc
04-29-2006, 09:08 PM
hi - on a small scale, this works fine
function find(a,b){
for(var c in b)if(b[c]==a)return c;}
useful for qualifying objects and getting events

var obj={name:"mark",age:32,smoker:true};
alert(find(32,obj));
//or
function showevent(a){
return find(arguments.callee.caller,a);}
//....
<button onclick="alert(showevent(this))">click</button>
when passed window or self, it breaks - just guessing, but i got past it a couple times on blind luck, and it seems like there's one property of the window object that doesnt have a constructor - eh now im doubting my memory... anyways if anybody knows how to loop through the window object props i'd appreciate hearing it

liorean
04-29-2006, 09:49 PM
The problem with the Window object is that it's a host object that has very broad responsibilities. That means it doesn't necessarily follow JavaScript rules all the time. It may contain COM objects that can be used in some specific way, but that can't be referenced from JavaScript, for instance.

There is no good way to get around this in iew. Moz, op and saf behave a little better when it comes to host objects though.

subhailc
04-29-2006, 10:52 PM
thanks liorean



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum