window.document.write("");

Object moved to here.