Why doesn't this window object have an eval function?
I ran into an interesting (?) Problem in the YUI rich edit demo in IE. When looking at the object window
for an editable frame of a frame used as a browser, I see the function is eval
undefined (by running the next one).
javascript:alert(document.getElementById("editor_editor").contentWindow.eval)
This only happens in IE (I've tested IE6 and IE8) and it doesn't happen in Firefox or Chrome.
All other window
functions and properties seem to be fine, now I understand that it eval
is not actually defined on window
but on a global object, but I realized that window
there is a global object in browsers (also eval
appears in all other windows, so why not on this?).
Does anyone know if this is a bug / limitation of knowledge in IE and how can I get to eval
in the context of this frame's global object? (I need side effects to be available for any of this frame).
a source to share
I found that you can do eval
magic in an iframe window in IE using execScript
first:
function evalIframe(iframeWin, command) {
if (!iframeWin.eval && iframeWin.execScript) {
iframeWin.execScript("null");
}
if (iframeWin.eval) {
iframeWin.eval(command);
} else {
alert("No eval!");
}
}
a source to share