谁能给VB控件webbrowser所有属性的解释

 我来答
n1Ce0080
2014-06-20 · 超过75用户采纳过TA的回答
知道答主
回答量:132
采纳率:0%
帮助的人:74.7万
展开全部
vb+Webbrowser控件详解 1、获得浏览器信息: Private Sub Command1_Click() WebBrowser1.Navigate " http://www.applevb.com " End Sub Private Sub Command2_Click() Dim oWindow Dim oNav Set oWindow = WebBrowser1.Document.parentWindow Set oNav = oWindow.navigator Debug.Print oNav.userAgent Set oWindow = Nothing Set oNav = Nothing End Sub 点击Command1浏览网页,点击Command2在立即窗口中输出浏览器信息。 2、弹出Webbrowser消息窗口 Dim oWindow Set oWindow = WebBrowser1.Document.parentWindow oWindow.confirm "abcd" VB调用webbrowser技巧集2 向Webbrowser中写入HTML内容的几种方法 首先在Form_Load中加入 WebBrowser1.Navigate "about:blank" 确保Webbrowser1可用 方法1: Dim s As String Dim stream As IStream s = "" s = s + "" s = s + "" s = s + " hello world " s = s + "" s = s + " WebBrowser1.Document.Write s 方法2: Dim o Set o = WebBrowser1.Document.selection.createrange Debug.Print o If (Not o Is Nothing) Then o.pasteHTML "哈哈" Set o = Nothing End If 方法3: '插入文本框 Dim o Set o = WebBrowser1.Document.selection.createrange o.execCommand "InsertTextArea", False, "xxx" vb调用Webbrowser技巧集3 1、页面滚动: Private Sub Command2_Click() WebBrowser1.Document.parentwindow.scrollby 0, 30 End Sub Private Sub Form_Load() WebBrowser1.Navigate " http://www.applevb.com " End Sub 点击Command2就可以使当前页面向下滚动30像素 2、判断页面是否可以前进后退 Private Sub Command1_Click() WebBrowser1.GoForward End Sub Private Sub Command2_Click() WebBrowser1.GoBack End Sub Private Sub Form_Load() WebBrowser1.Navigate " http://www.applevb.com " End Sub Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean) If (Command = CSC_NAVIGATEBACK) Then Command2.Enabled = Enable End If If (Command = CSC_NAVIGATEFORWARD) Then Command1.Enabled = Enable End If End Sub VB调用webbrowser技巧集4 1、如何使网页不出现滚动条: Private Sub mnuScroll1_Click() @#注意:必须在网页完全显示之后才可以运行 WebBrowser1.Document.body.Scroll = "no" @#不显示滚动条的办法 End Sub Private Sub mnuScroll2_Click() @#注意:必须在网页完全显示之后才可以运行 WebBrowser1.Document.body.Scroll = "Auto" @#显示滚动条的办法 End Sub 2、如何获得网页中被选中部分的HTML: Private Sub Command1_Click() Dim objSelection Dim objTxtRange Set objSelection = WebBrowser1.Document.selection If Not (objSelection Is Nothing) Then Set objTxtRange = objSelection.createRange If Not (objTxtRange Is Nothing) Then Debug.Print objTxtRange.htmlText Set objTxtRange = Nothing End If Set objSelection = Nothing End If End Sub Private Sub Form_Load() WebBrowser1.Navigate " http://www.applevb.com " End Sub Navigate 方法的语法格式为: WebBrowser 控件名.Navigate URL [Flags,][TargetFrameName,][PostData,][Headers] ---- WebBrowser 控件支持的主要方法有: GoBack ———回退到上一屏。 GoForward ———进入到下一屏。 GoHome ———回家。 即回到主页。 Stop ———停止导航。 Refresh ———刷新。 Navigate ———导航。 ---- WebBrowser 控件所响应的事件: ---- BeforeNavigate 事件———在开始导航前发生。 一般在此获取完整的URL 字符串。 ---- WebBrowser 控件最主要的参数: ---- URL ———获得导航用的标准URL 字符串。 例如: 它能将” www.MicroSoft.Com ”自动翻译为” http://www.MicroSoft.Com ”.URL 是Uniform Resource Locator 的缩写, 是在Internet 的WWW 服务程序上用于指定信息位置的表示方法。 使用WebBrowser的Navigator或者Navigator2方法打开一个asp文档并且传递 参数进去,但是asp文档无法获得参数,请教是什么原因? vb源码: Private Sub cmdSubmit_Click() Dim strURL As String, strFormData As String Dim strData As String strURL = Trim$(txtURL.Text) strFormData = "name=" & Trim$(txtName.Text) & "&password=" & Trim$(txtPassword.Text) Call WBTest.Navigate2(strURL, 64, "_blank", strFormData, "hello") End Sub asp源码: <%@ Language=VBScript %> <% dim strName dim strPassword strName=Trim(Request.Form("name")) strPassword=Trim(Request.Form("password")) Response.Write(strName) Response.Write(strPassword) if strName="KingZhang" and strPassword="123456" then Response.Write("登陆成功") else Response.Write("非法登陆用户!") end if %> ********************************************************************* Option Explicit Private Sub Command1_Click() Dim szValue As String WebBrowser1.Document.body.innerHTML = " method=post action=http://地址/xxx.php> " WebBrowser1.Document.Forms("post").submit End Sub Private Sub Form_Load() WebBrowser1.Navigate2 "about:blank" End Sub Top ******************************************************************** 请问:在WebBrwoser控件里提供的Navigate或者Navigate2方法中提供了传递数据 的参数,调用方式为:WebBrowser1.Navigate2(URL,[Flags], [TargetFrameName],[PostData],[Headers]) 其中PostData参数就是一个提交参数字符串,例如"name=aaa&password=123", 但问题是为什么这个方法并不是有效的,服务器端不能取得数据? 如果这个方法是有效的话就不需要用一段html代码模拟这种调用了。 下面代码能检测出程序post出去的消息 Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean) MsgBox PostData End Sub WebBrowser的8个方法和13个属性 WebBrowser的8个方法和13个属性,以及它们的功能: 方法 说明 GoBack 相当于IE的“后退”按钮,使你在当前历史列表中后退一项 GoForward 相当于IE的“前进”按钮,使你在当前历史列表中前进一项 GoHome 相当于IE的“主页”按钮,连接用户默认的主页 GoSearch 相当于IE的“搜索”按钮,连接用户默认的搜索页面 Navigate 连接到指定的URL Refresh 刷新当前页面 Refresh2 同上,只是可以指定刷新级别,所指定的刷新级别的值来自RefreshConstants枚举表, 该表定义在ExDisp.h中,可以指定的不同值如下: REFRESH_NORMAL 执行简单的刷新,不将HTTP pragma: no-cache头发送给服务器 REFRESH_IFEXPIRED 只有在网页过期后才进行简单的刷新 REFRESH_CONTINUE 仅作内部使用。在MSDN里写着DO NOT USE! 请勿使用 REFRESH_COMPLETELY 将包含pragma: no-cache头的请求发送到服务器 Stop 相当于IE的“停止”按钮,停止当前页面及其内容的载入 属性 说明 Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDispatch)。如果在宿主对象中自动化对象无效,这个程序将返回WebBrowser 控件的自动化对象 Parent 返回WebBrowser控件的父自动化对象,通常是一个容器,例如是宿主或IE窗口 Container 返回WebBrowser控件容器的自动化对象。通常该值与Parent属性返回的值相同 Document 为活动的文档返回自动化对象。如果HTML当前正被显示在WebBrowser中,则 Document属性提供对DHTML Object Model的访问途径 TopLevelContainer 返回一个Boolean值,表明IE是否是WebBrowser控件顶层容器,是就返回true Type 返回已被WebBrowser控件加载的对象的类型。例如:如果加载.doc文件,就会返 回Microsoft Word Document Left 返回或设置WebBrowser控件窗口的内部左边与容器窗口左边的距离 Top 返回或设置WebBrowser控件窗口的内部左边与容器窗口顶边的距离 Width 返回或设置WebBrowser窗口的宽度,以像素为单位 Height 返回或设置WebBrowser窗口的高度,以像素为单位 LocationName 返回一个字符串,该字符串包含着WebBrowser当前显示的资源的名称,如果资源 是网页就是网页的标题;如果是文件或文件夹,就是文件或文件夹的名称 LocationURL 返回WebBrowser当前正在显示的资源的URL Busy 返回一个Boolean值,说明WebBrowser当前是否正在加载URL,如果返回true 就可以使用stop方法来撤销正在执行的访问操作 如何利用 WebBrowser 控件,显示 .GIF 动画? 要有一定的网页知识(HTML、JavaScript、CSS) 注意细节: 没有"滚动条"和"鼠标右键弹出的 IE 上下文菜单",".HTM 源文件" ... 我写了一个,效果还真不错! 'Objects: Form1、Command1、CommonDialog1、WebBrowser1 Option Explicit Private Sub Command1_Click() CommonDialog1.ShowOpen If VBA.Len(VBA.Trim(CommonDialog1.FileName)) > 0 Then Dim p As stdole.StdPicture Dim sPath As String sPath = VBA.Trim(VBA.Trim(CommonDialog1.FileName)) Set p = VB.LoadPicture(sPath) WebBrowser1.Width = p.Width * 16 / 26 WebBrowser1.Height = p.Height * 16 / 26 ' WebBrowser1.Navigate "about:blank" WebBrowser1.Document.open WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "WebBrowser1.Document.writeln " WebBrowser1.Document.writeln "WebBrowser1.Document.writeln " " WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" End If End Sub Private Sub Form_Load() Command1.Caption = "&Open" WebBrowser1.Navigate "about:blank" WebBrowser1.Document.open WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.Close End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式