Reputation:
I've prepared view that loads aync another view and then replace current with document.write (yes, I want to replace whole page!):
$.ajax({
type: "GET",
url: myUrl,
data: null,
async: true,
success: function (result) {
document.close();
document.open();
document.write(result);
document.close();
},
error: function (req, status, error) {
$("#loading-div").html("error");
}
});
The content is full view with own scripts and css styles. When using IE or Chrome everything works fine. When I load page within firefox, loaded page via document.write doesn't seems to be working properly - especially scripts (some works, some don't).
I can't use innerHTML due to scripts that are not evaluated.
Why it doesn't work properly only in Firefox (even IE can handle it!)?
Upvotes: 0
Views: 87
Reputation: 35064
The specification requires document.open
to create a new global. Firefox does that. Chrome does not; I can't speak for IE.
So if you're depending on the old global sticking around, your script will work in Chrome but not Firefox.
Upvotes: 1