Of course - how obvious, silly me, I'm new to JSON and had a mental block about the eval thing. The [0] you mentioned shouldn't have been there, I was simplifying my code before posting and forgot to remove it.
Thanks! On Nov 2, 3:58 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote: > That code shouldn't work in any browser. The fact that it works in Firefox > is actually considered a bug, which I believe is being fixed in 3.0. > > eval() is supposed to be a method of the window object (i.e. a global > function). It isn't supposed to be available as a method of every object. > > What is the purpose of the eval()? And what is the [0] for in your first > eval? I don't see an array in the code, nor any apparent reason to use > eval(). > > Would this be the code you're looking for? > > function openPage( item ) { > alert( menuitems[item] ); > } > > -Mike > > > From: mngd > > > The following code works in FF but generates errors in IE6. > > I'm completely stumped - any feedback appreciated... > > > ------------------------------------------------------------ > > > <script type="text/javascript"> > > > var menuitems = { > > "home" : "home.html" > > } > > > function openPage(item) { > > > // this is what I need to do, works in FF > > alert(menuitems.eval(item)[0]); > > > // this works in IE and FF - returns 'home' > > // (without the quotes) > > alert(item); > > > // this works in FF - returns 'home.html' (without quotes) > > // generates error in IE6 - 'Object doesn't support this > > // property or method' > > alert(menuitems.eval(item)); > > > } > > > </script> > > > <h1>Using eval on a JSON array in IE6</h1> > > > <a href="javascript:openPage('home')">home</a> > > > ------------------------------------------------------------