Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post

    looping self/window

    hi - on a small scale, this works fine
    Code:
    function find(a,b){
    	for(var c in b)if(b[c]==a)return c;}
    useful for qualifying objects and getting events
    Code:
    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

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks liorean


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •