1. 保存源代码么? function GetSource(Document:IHTMLDocument2):String; var i:Integer;pElement:IHTMLElement; begin Result:=''; for i:=0 to Document.all.length -1 do begin Document.all.item(i,i).QueryInterface(IID_IHTMLElement,pElement); if CompareText(pElement.tagName,'HTML') =0 then begin Result:=pElement.outerHTML; exit; end; end; end;2. 直接编辑 (WebBrowser1.Document as IHTMLDocument2).exexCommand('EditMode',false,EmptyParam);
呵,Eastunfail,把你的函数改了一下...function GetSource(Document:IUnknown):String; var i:Integer;pElement:IHTMLElement; doc:IHTMLDocument3; begin doc:=Document as IHTMLDocument3; Result:=doc.documentElement.outerHTML;end;
保存源代码么?
function GetSource(Document:IHTMLDocument2):String;
var i:Integer;pElement:IHTMLElement;
begin
Result:='';
for i:=0 to Document.all.length -1 do
begin
Document.all.item(i,i).QueryInterface(IID_IHTMLElement,pElement);
if CompareText(pElement.tagName,'HTML') =0 then
begin
Result:=pElement.outerHTML;
exit;
end;
end;
end;2.
直接编辑
(WebBrowser1.Document as IHTMLDocument2).exexCommand('EditMode',false,EmptyParam);
var
i:Integer;pElement:IHTMLElement;
doc:IHTMLDocument3;
begin
doc:=Document as IHTMLDocument3;
Result:=doc.documentElement.outerHTML;end;
2 查询HTMLDocument对象的IPersistStream
3 IPersistStream::Save
4 用GetHGlobalFromStream获得内存流的句柄
5 用GlobalLock和GlobalUnlock访问HTML数据