procedure DoChangePageCode(Doc: IDispatch); var tr: IHTMLTxtRange; s: string; begin tr := ((Doc as IHTMLDocument2).body as IHTMLBodyElement).createTextRange; s := tr.htmlText; // 取出页面的代码 // 此处就能随意改了 tr.pasteHTML(s); // 改完后的代码写回去 end;本文来自Delphi之窗,原文地址:http://www.52delphi.com