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
    New Coder
    Join Date
    Dec 2009
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Angry my code works in google chrome, but not firefox!

    this code works in google chrome, but not in firefox.
    Code:
    function merge(obj1, obj2) {
     var a ={};
      for (var p in obj1) {
        try {
          // Property in destination object set; update its value.
          if ( obj1[p].constructor==Object ) {
            a[p] = merge(a[p], obj1[p]);
    
          } else {
            a[p] = obj1[p];
    
          }
    
        } catch(e) {
          // Property in destination object not set; create it and set its value.
          a[p] = obj1[p];
    
        }
      }
        for (var p in obj2) {
        try {
          // Property in destination object set; update its value.
          if ( obj2[p].constructor==Object ) {
            a[p] = merge(a[p], obj2[p]);
    
          } else {
            a[p] = obj2[p];
    
          }
    
        } catch(e) {
          // Property in destination object not set; create it and set its value.
          a[p] = obj2[p];
    
        }
      }
    
      return a;
    }
    var d=function(){'c';}
    var a ={a:{b:'c'},b:'c'}
    var b ={c:a,d:d};
    var c = merge(window,b);
    WHY?!?!?!?!?!?!?!?!?!?!?!?!??!?!?!?!
    Open source. DO IT!!! SUPPORT IT!!! PREACH IT!!!
    -- The JSNerd

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Have you used Firebug, set break points and walk through the code to see where it fails? Add watches to see what the variables are.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts
    it screws up at
    Code:
        } catch(e) {
          // Property in destination object not set; create it and set its value.
          a[p] = obj1[p];
    
        }
    it says

    Error: uncaught exception: [Exception... "Operation is not supported" code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location: "file:///C:/Program%20Files/a%20free%20javascript%20editor/YaldexTemp$$$8.htm Line: 26"]
    Open source. DO IT!!! SUPPORT IT!!! PREACH IT!!!
    -- The JSNerd


  •  

    Tags for this Thread

    Posting Permissions

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