[This post is here, under marginal topicality, because I'm awaiting approval to get on the Rails-spinoffs mailing list.
[Hope the post doesn't influence the approval... ]
The calling page has these elements:
<iframe id='grinder' src='sample.html' >
So here's most of the page which the iframe hits:
Note that both the outer and inner page have a span with the same ID.
The outer page calls Ajax goodies that generate some JS looking like this:
Element.update("update_me", "here I B");
The page sends that, as a string, into this JS (in application.js):
var grinder = $('grinder');
var doc = grinder.contentDocument;
if (!doc) doc = grinder.document;
document.write("your browser sucks");
So that contains enough logic to find the iframe's document, and it works for Firefox, IE, Konqueror, and Opera. The code calls evaluate() with the document where we need the evaluation context, and the string with our source.
function evaluate(doc, sauce)
var s = doc.createElement('script');
//s.defer = true; // <-- no effect
s.text = sauce;
var body = doc.getElementsByTagName('body').item(0);
body = doc.body;
That creates a <script> block, sticks our string in as its contents, and pushes the block to the end of our <body> tag. Now here's the bug:
Firefox updates the inner <span id='update_me'>, and IE updates the outer one.
If I remove the outer <span id='update_me'>, then IE simply can't find it and throws an error. Even though it evaluates a script block clearly in the context of the inner iframe.
I have tried calling the script from setTimeout, and from a button's onclick handler.
Is there some script.aculo.us way to fix (yet another) bug in IE? Or is this a bug in prototype.js?