用Twebbrowser打开网页时,如何判断打开的网页是正确还是错误的。错误网页包括:找开指定网页,无法显示网页等。分不够再加,在线等待。
解决方案 »
- 关于IDHTTP的返回问题
- delphi中的float型的奇怪问题?
- 200分求一个功能简单的delphi抽奖程序源码,各位一定要帮忙啊?
- 如何获得ClientDataSet待执行的SQL语句?
- delphi里有没有类似于VB的模糊字符串比较如: if str like "*元/盒" then
- 高手请教,,不知道怎么办?
- 数据库开发用什么样的前台开发工具最好。
- 谁能给个dll编程的例子?
- winexec(XXX,sw_show); xxx变量怎么样处理?
- 请问谁有关于网吧的资料,最好有源程序就好拉,.......
- 关于Dll中的窗体问题,求解!!!!!!!!!!!!!
- 来者有分!!帮忙看看!帮忙看看这个为什么不能运行?
如果超时,就为读取未成功
就让WebBrowser读取('about:blank')空页面
返回一个Nil的IHTMLDocument2文档;function TForm1.GetTheHtmlDoc(Url: WideString = ''): IHTMLDocument2;
var
I: Integer;
begin
// StatusBar1.Panels[2].Text := '从Internet读文档……';
Result := nil;
if Url = '' then
begin
Web.Navigate('about:blank');
Exit;
end; //if Url = ''
Web.Navigate(Url);
for I := 0 to 100 * 20 do
begin
Sleep(50);
APPlication.ProcessMessages;
if Web.ReadyState = READYSTATE_COMPLETE then
begin
Result := Web.document as IHTMLDocument2;
// StatusBar1.Panels[2].Text := '正确取得文档';
Break;
end;
{ if CancelByUser = True then
begin
Break;
end;}
end; //for
if Result = nil then
begin
// StatusBar1.Panels[2].Text := '____超时错';
Web.Navigate('about:blank');
{ While 1 = 1 Do
If Web.ReadyState <> READYSTATE_COMPLETE Then
WaitAMoment
Else
Begin
Result := Web.document As IHTMLDocument2;
Break;
End;}
end; // If Result = Nil Then}end;
const pDisp: IDispatch; var URL: OleVariant);
var
document,textrange: olevariant;
begin
document:=WebBrowser1.Document;
TextRange:=document.body.createtextrange; if textrange.text='' then
begin
showMessage('正常:200');
end
else if textrange.findtext('404',4000,0) then
begin
showMessage('无法找到文件:404');
end
else if i textrange.findtext('500',4000,0) then
{...}
end;