打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
delphi去除webbrowser滚动条的正确方法(流传的都不对)

delphi去除webbrowser滚动条的正确方法(流传的都不对)

分类: delphi webbrowser 468人阅读 评论(0) 收藏 举报

今天乱翻论坛,回答了一个网友的问题。

http://topic.csdn.net/u/20101006/08/a372ebf1-838e-4653-a7f7-517fac560f47.html?seed=140121506&r=69102800#r_69102800

网上给出的东西好些都不准确啊,今天在这里记下来,省的以后忘掉。

网上流传的去掉滚动条的方法是:

Wb1.OleObject.Document.Body.style.border := 'none';

或者

Wb1.OleObject.Document.Body.style.border := 'no';

这两条都是不对的。

首先,第一条会报错,属性设置错误。只有3种:

yes

no

aotu

原文说明如下:

sScrollString thatspecifies or receives one of the following values.

yes
Default. Scroll bars are turned on.
no
Scroll bars are turned off.
auto
Scroll bars are shown when the page content exceeds the client area.

The property is read/write.The property has a default value of yes.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, seeAbout Dynamic Properties.

Remarks

With Microsoft Internet Explorer 6 and later, when you use the !DOCTYPE declaration to specify standards-compliant mode, this attribute applies to theHTML element. When standards-compliant mode is not specified, as with earlier versions of Windows Internet Explorer, this attribute applies to theBODY element, not theHTML element

懒得翻译,反正是delphi用不了这个方法,也没有上js测试。

我记得以前好像有一个style属性来着,找了找,加上:

    WB1.oleobject.Document.body.Scroll := 'hidden';

这样一来,下面的滚动条没有了,右面还有一个。仔细想了一下,发现里面有个问题,body的大小和twebbrowser的大小本来就是两个概念,仅仅设置hidden了,body的大小还是没有改变,里面不知道那里又出来一个滚动条,改动了一下body的大小:

    WB1.oleobject.Document.body.style.width:= '200px';
    WB1.oleobject.Document.body.style.height:= '300px' ;

于是这次成功了。不过不完善,还有一个灰色的边框啊!

 

void CMFCReproDlg::OnBeforeNavigate2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR*

TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)
{
    static int nCount = 0;

    nCount++;
    if (nCount == 2) // this should be the navigate for the first frame in frameset
    {
        IWebBrowser* pWB = NULL;
        HRESULT hr = pDisp->QueryInterface(IID_IWebBrowser, (void**)&pWB);
        COleVariant ve((long)0);
        pWB->Navigate(::SysAllocString(L"http://myserver/mydirectory/framesetChild.htm"), &ve, &ve, &ve, &ve);
        *Cancel = VARIANT_TRUE;
    }
}
//以下是附录
Visual C 5.0 uuid.lib不包含IID_IWebBrowser和CLSID_WebBrowser的定义,
但是二者的 ID很容易在exdisp.h中找到,我从中提出它们:
/* EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B */
IID const IID_IWebBrowser={0xEAB22AC1, 0x30C1, 0x11CF, 0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B};
 /* 8856F961-340A-11D0-A96B-00C04FD705A2 */
CLSID const CLSID_WebBrowser={0x8856F961, 0x340A, 0x11D0, 0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
delphi webbrower的滚动条控制
C#中webBrowser加载页面中访问不同域的iFrame引发System.UnauthorizedAccessException异常的解决办法
delphi WebBrowser的使用方法详解(五)
WebBrowser 操作记要(万一博客)
WebBrowser介绍——Javascript与C 互操作
读取WebBrowser网页脚本中的变量
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服