procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); begin tag:=1; //去掉Webbrowser1滚动条的标志 end;
第二步:
procedure TForm1.SpeedButton1Click(Sender: TObject); var Doc: IHTMLDocument2; begin tag := 0; //去掉Webbrowser1滚动条的标志 WebBrowser1.Navigate2(’http://www.163.com’); while (tag=0) do Application.ProcessMessages; WebBrowser1.oleobject.Document.body.Scroll := ‘no’; end;
注意:使用前必须在uses中加入mshtml;
==========================题外话 //去掉滚动条后如何翻页呢?用如下代码
var Doc: IHTMLDocument2; begin Doc :=WebBrowser1.Document as IHTMLDocument2; Doc.Get_ParentWindow.Scroll(x,y); end; ^^^你要滚动的位置 webbrowser不弹出错误提示框 设置一下这个属性:webbrowser1.silent :=true
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin //屏敝网页右键 if Msg.message = WM_RBUTTONDOWN then begin //如果去掉下面这行就是屏蔽右键菜单,现在为自定义右键菜单 // popupmenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); Handled := True; end; end;