Skip to content

Instantly share code, notes, and snippets.

@jstotz
Created March 29, 2010 20:20
Show Gist options
  • Save jstotz/348356 to your computer and use it in GitHub Desktop.
Save jstotz/348356 to your computer and use it in GitHub Desktop.
function buffered_write(func) {
var old_write = document.write;
var buffer = '';
document.write = function(string) {
buffer += string;
};
func();
document.write = old_write;
return buffer;
}
document.write('Original, before');
var result = buffered_write(function() {
document.write('I am overloaded');
document.write('Here I am again');
});
console.log('Result:');
console.log(result);
document.write('Original, after');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment