Created
March 29, 2010 20:20
-
-
Save jstotz/348356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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