Johanna: Scope von eval() im IE anders als im FF???

Beitrag lesen

http://blog.zimki.com/tomi/2006/08/07/javascript-eval

Gut, das beweist, dass dieses Verhalten proprietär ist.

Jetzt muss ich nochmal nerven, sorry. Ich bin der Meinung, dass das IE Verhalten doch nicht ganz korrekt ist. Und zwar steht im MSDN dass eval eine Methode des Global Object ist, als window, oder? Weiter steht darüber:

"An intrinsic object whose purpose is to collect global methods into one object. The Global object has no syntax. You call its methods directly. The Global object is never used directly, and cannot be created using the new operator. It is created when the scripting engine is initialized, thus making its methods and properties available immediately." (http://msdn2.microsoft.com/en-us/library/52f50e9t.aspx)

Über eval steht u.a. folgendes drin: "The code passed to the eval method is executed in the same context as the call to the eval method." (http://msdn2.microsoft.com/en-us/library/12k71sw7.aspx)

Das selbe steht übrigens hier: "The scope of eval code is identical to the scope of the calling code." (http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Predefined_Functions:eval_Function)

Daraus folgere ich:

  • eval ist immer vorhanden
  • eval hängt am globalen Objekt, also an window
  • deshalb lässt IE auch window.eval(...) zu, während er document.getElementById('xy').eval(...) nicht mag
  • da "code passed to the eval method is executed in the same context as the call to the eval method." sollte doch auch mein Aufruf das gewünschte Ergebnis liefern - siehe FF.

Siehst das immer noch anders, wenn ja warum?

Vielleicht findest du ja nochmal die Zeit.

Danke, Johanna