Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2010, 10:45 PM   PM User | #1
mr.jsnerd
New Coder

 
Join Date: Dec 2009
Posts: 38
Thanks: 3
Thanked 0 Times in 0 Posts
mr.jsnerd is an unknown quantity at this point
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
mr.jsnerd is offline   Reply With Quote
Old 03-21-2010, 02:24 AM   PM User | #2
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 03-21-2010, 02:20 PM   PM User | #3
mr.jsnerd
New Coder

 
Join Date: Dec 2009
Posts: 38
Thanks: 3
Thanked 0 Times in 0 Posts
mr.jsnerd is an unknown quantity at this point
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
mr.jsnerd is offline   Reply With Quote
Reply

Bookmarks

Tags
chrome, compatibility, firefox, google, works

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:05 AM.


Advertisement
Log in to turn off these ads.