View Full Version : looping self/window

04-29-2006, 10: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};
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

04-29-2006, 10: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.

04-29-2006, 11:52 PM
thanks liorean