Replaces the current document with a valid HTML document using HTMLDocument.open, write and close.