I have to grab a snippet of JS that has document.write in it – this causes the page to go blank once the document.write renders. I was able to work around this by redefining document.write and pass the response of the script to a function that I use to output the response from the getScript() jQuery function. I am having an issue however with other elements and scripts that load later in the page that my redefining is preventing to output on the page. How can I set document.write back to the default functionality after the jQuery getScript() has completed?
$.getScript('somescript.com/script/', function(){
//Prevent document.write normal behavior
document.write = function(markup) {
fullMarkup += markup;
appendResponse(markup);
}
}
});
Just save the original refernce to
document.writein some variable and restore it, after you used the replacement.and after succesfull loading (and execution) of your script