//-------------------------------------------在这个 事件中 屏蔽图像 会爆出异常 软件会退出 很严重
procedure TForm1.webbrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var wd : IHTMLWindow2;
bw : IWebBrowser2; tt:tstringlist;
function HtmlWindowToHtmlWebBrowser(const ADsp : IDispatch) : IWebBrowser2;
var
isp : IServiceProvider;
begin
Result := nil;
if not Assigned(ADsp) then Exit;
isp := ADsp as IServiceProvider;
isp.QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, Result);
end;
var doc2:ihtmldocument2;
i,j,k:integer; sa,a,b,c:string;
begin
//WebBrowser1.OleObject.document.getElementById('bgDiv').style.BackGroundImage;
{ try
k:=(self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('img').length -1;
for I := 0 to k do
begin application.ProcessMessages;
try
sa:=((self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('img').item(i,varempty)as ihtmlelement).outerHTML;
if (pos('http://static.geetest.com/pictures/gt/',sa)=0) and (pos('http://login.sina.com.cn/cgi/pin.php?r=',sa)=0) then
begin
((self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('img').item(i,varempty)as ihtmlelement).setAttribute('src','about:blank',0);
end;
except end;
end;
except end;
try
k:=(self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('div').length -1;
for I := 0 to k do
begin
try application.ProcessMessages;
sa:=((self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('div').item(i,varempty)as ihtmlelement).outerHTML;
if (pos('http://static.geetest.com/pictures/gt/',sa)=0) and (pos('http://login.sina.com.cn/cgi/pin.php?r=',sa)=0) then
begin
((self.webbrowser1.Document as ihtmldocument3).getElementsByTagName('div').item(i,varempty)as ihtmlelement).style.background:='about:blank';
end;
except end;
end;
except end;
}
end;
//=========================在这个事件中 屏蔽图像 会爆出异常 软件会退出 很严重