J
jbas
Unregistered / Unconfirmed
GUEST, unregistred user!
我用下面的代码,可是不行,会出现乱码,请问我该怎么做?
谢谢了!
procedure TFmMain.WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
d:Variant;
htMsg:string;
index:Integer;
document: IHTMLDocument2;
ole_index: OleVariant;
doc_all: IHTMLElementCollection;
frame_dispatch: IDispatch;
frame_win: IHTMLWindow2;
frame_doc: IHTMLDocument2;
frameCount: Integer;
begin
try
document := WebBrowser1.Document as IHTMLDocument2;
if Assigned(document) then
begin
if(document.frames.length=0) then
begin
d:=WebBrowser1.OleObject.Document;
htMsg:=d.title;
end
else
begin
for index:=1 to document.Frames.Length do
begin
ole_index := index-1;
frame_dispatch := document.Frames.Item(ole_index);
if Assigned(frame_dispatch) then
begin
frame_win := frame_dispatch as IHTMLWindow2;
htMsg:=frame_win.document.title;
showmessage('pp'+htMsg);
end;
end;
end;
end;
Except
end;
//d:=WebBrowser1.Document;
// htMsg := WebBrowser1.OleObject.Document.title;
FmMain.Caption:=htMsg;
showmessage('hixh'+htMsg);
if((htMsg='没有可以显示的页面') or (htMsg='HTTP 404 未找到')) then
begin
d.Write('<b>出错了!</b>');
d.Close;
end;
end;
谢谢了!
procedure TFmMain.WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
d:Variant;
htMsg:string;
index:Integer;
document: IHTMLDocument2;
ole_index: OleVariant;
doc_all: IHTMLElementCollection;
frame_dispatch: IDispatch;
frame_win: IHTMLWindow2;
frame_doc: IHTMLDocument2;
frameCount: Integer;
begin
try
document := WebBrowser1.Document as IHTMLDocument2;
if Assigned(document) then
begin
if(document.frames.length=0) then
begin
d:=WebBrowser1.OleObject.Document;
htMsg:=d.title;
end
else
begin
for index:=1 to document.Frames.Length do
begin
ole_index := index-1;
frame_dispatch := document.Frames.Item(ole_index);
if Assigned(frame_dispatch) then
begin
frame_win := frame_dispatch as IHTMLWindow2;
htMsg:=frame_win.document.title;
showmessage('pp'+htMsg);
end;
end;
end;
end;
Except
end;
//d:=WebBrowser1.Document;
// htMsg := WebBrowser1.OleObject.Document.title;
FmMain.Caption:=htMsg;
showmessage('hixh'+htMsg);
if((htMsg='没有可以显示的页面') or (htMsg='HTTP 404 未找到')) then
begin
d.Write('<b>出错了!</b>');
d.Close;
end;
end;