1.
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
Links:IHTMLElementCollection;
Doc:IHTMLDocument2;
len:integer;
item:olevariant;
begin
Doc:=webbrowser1.document as IHtmlDocument2;
links:=Doc.links;
len:=links.length;
if len>0 then
begin
Item:=links.item(0,varEmpty);
item.click;
end;
end;
2.3.在ie5中
uses ....,activex,mshtml;
var
HTMLDocument: IHTMLDocument2;
PersistFile: IPersistFile;
begin
...
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
Persist := HTMLDocument as IPersistFile;
Persist.Save(StringToOleStr('test.htm'), True); while HTMLDocument.readyState <> 'complete' do
Application.ProcessMessages;
...
end;
兄弟,给分吧,哈哈
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
Links:IHTMLElementCollection;
Doc:IHTMLDocument2;
len:integer;
item:olevariant;
begin
Doc:=webbrowser1.document as IHtmlDocument2;
links:=Doc.links;
len:=links.length;
if len>0 then
begin
Item:=links.item(0,varEmpty);
item.click;
end;
end;
2.3.在ie5中
uses ....,activex,mshtml;
var
HTMLDocument: IHTMLDocument2;
PersistFile: IPersistFile;
begin
...
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
Persist := HTMLDocument as IPersistFile;
Persist.Save(StringToOleStr('test.htm'), True); while HTMLDocument.readyState <> 'complete' do
Application.ProcessMessages;
...
end;
兄弟,给分吧,哈哈
var
item : Olevariant;
begin
if WebBrowser1.OleObject.Document.All.Links.Length < 1 then exit;
item := Webbrowser1.OleObject.Document.All.Links.item(0);
end;
对IHTMLElementCollection 可以看看MSDN对于后两个问题
如果你不对document的内容进行修改的话,hubdog的方法就可以了
但如果你修改过,用这种方法就保存不了修改的内容.我也在为这个问题
困惑.ie5以上可以用html对象的outerHtml取得所有内容.但ie5以下,对
body外的好像就没办法了.