This is because some documents alter itself using `document.write`,
which can insert again tags (img, style, script) that expect to live in
a normal environment.
This commit also refactors some of the `retrieveFile` logic. The
function should behave differently when called in the iframe vs the
parent document.