TWebBrowser滚动条的显示问题探讨。

有时候我们查看网页信息,只想查看某些特定区域的信息,那么这时候我们可能会这么做:

  //获取源代码
  D := FCurWebBrowser.Document as IHTMLDocument2;
  e :=d.body as IHTMLElement;
  e2 :=e as IHTMLElement2;
  cp :=e2.createControlRange as IHTMLControlRange;
  d2 :=FCurWebBrowser.Document as IHTMLDocument2;
  //获取验证码图片

  coll :=(d.all.tags('img') as IHTMLElementCollection);
  d2.body.style.visibility :='hidden';

先让所有信息隐藏。

然后遍历所有内容:

for i := 0 to coll.Length - 1 do
  begin
  //循环取出每个url
    elem := (coll.item(i,0) as IHTMLElement);
    //当找到元素之后
          elem.style.visibility :='visible';
          elem.scrollIntoView(True);
    end;
这样能显示特定内容,但是又会遇到另一个问题那就是滚动条还在显示。很烦人哦。

为了应对这个问题在页面加载结束之后可以这样操作:

procedure TMainFrm.BaiduWebBrowserDocumentComplete(ASender: TObject; const
    pDisp: IDispatch; var URL: OLEVariant);
begin
  FCurWebBrowser.OleObject.Document.Body.Scroll := 'no';
  FCurWebBrowser.OleObject.Document.Body.style.border := 'none';
  FCurWebBrowser.OleObject.Document.Body.Style.margin := '0px';
end;

这样就可以让滚动条消失了。不过消失速度老慢了。还能看到过程。郁闷ing

大家有木有好的方法?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值