Tag: webbrowser预览模式: 普通 | 列表
利用HtmlElement可以访问document中的元素,但是HtmlElement 仅公开所有元素共有的那些属性,如id/name/tagname等,对于未公开的属性,如href/alt等,则需要通过getAttribute()方法来获取。如要获取相册中的url,可以用下面的方法: 
      element.getAttribute(“href”)          //该方法假定element已经对应这个元素
      但是对于IE的元素,用element.getAttribute(“class”)却不能获取到class的值。
      问题原因是不同浏览器所支持的属性不同,对于IE,要获取class属性,可用classname属性来替代,element.getAttribute(“classname”)
      要解决不同浏览器对此的兼容性问题,可用以下类似的代码:
      if (element.getAttribute(”className”) == “class的名字” ||element.getAttribute(”class”) == “class的名字”)
      还有其他一些属性会有类似的兼容性问题。

Tags: webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 532

webbrowser浏览器版本设置

 Browser Emulation

Windows Internet Explorer 8 and later. The FEATURE_BROWSER_EMULATION feature defines the default emulation mode for Internet Explorer and supports the following values.

 

Value Description
11001 (0x2AF9 Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
10001 (0x2711) Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
10000 (0x02710) Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
9999 (0x270F) Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the declared !DOCTYPE directive. Failing todeclare a !DOCTYPE directive causes the page to load in Quirks.
9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
 
8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directivecauses the page to load in Quirks.
8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
 
7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.

Tags: webbrowser ie

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1390

vb获取webbrowser中网页的完整html源码

WebBrowser1.document.documentElement.outerHTML
或者
WebBrowser1.document.all(0).outerHTML
不过这些都是不包含嵌套在内的frame里的网页源码。

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2785

VB中webbrowser调用IE版本问题

  做了一个Winform的项目。项目里使用了WebBrowser控件。以前一直都以为WebBrowser是直接调用的系统自带的IE,IE是呈现出什么样的页面WebBrowser就呈现出什么样的页面。其实并非如此。我的Winform程序加载了一个Web项目。这个项目对IE8一下的浏览器布局兼容不是太好。本机使用的是IE8,项目是.net4.0。用本机浏览器查看Web项目没有任何问题。可是调用Winform里的WebBrowser浏览Web项目页面却出现了布局问题。所以我就开始质疑到底WebBrowser是不是IE8的模式啊。于是打开IETester,从IE9一直到IE5都查看了一遍,发现最像WebBrowser布局呈现的是IE7模式下。在搜了一些相关资料原来WebBrowser使用的是IE的兼容模式进行浏览(IE7模式)。

  如何让WebBrowser引用IE 8 呢。可以通过注册表的新增键值实现

  打开HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

查看更多...

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3073

VB编程之webbrowser自动选择下拉框

 直接上代码:

ASP/Visual Basic代码
  1. For i = 0 To WebBrowser1.Document.getElementById("下拉框ID").Options.length - 1  
  2.     If WebBrowser1.Document.getElementById("下拉框ID").Options(i).Value = "2" Then  
  3.         WebBrowser1.Document.getElementById("下拉框ID").Options(i).Selected = True  
  4.         Exit For  
  5.     End If  
  6. Next  

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 1 | 引用: 0 | 查看次数: 2828

VB关于webbrowser相关操作大全

 内容节选:

代码1:

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)

Dim frm As Form1

查看更多...

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2763

VB Webbrowser控件详解

新加内容:

提交表单form1:
Private Sub Command1_Click()
WebBrowser1.Document.Forms("form1").submit
End Sub

将form1中的名为u的属性设为不可用:
Private Sub Command2_Click()
WebBrowser1.Document.Forms("form1").u.setAttribute "disabled", "disabled"
End Sub

将form1中的名为u的Text框中的内容设为abc:
Private Sub Command2_Click()
WebBrowser1.Document.Forms("form1").u.setAttribute "value", "abc"
End Sub

查看更多...

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 5405

VB中屏蔽webbrowser的弹出错误对话框!

Private Sub WebBrowser1_DownloadBegin()
WebBrowser1.Silent = True
End Sub

Private Sub WebBrowser1_DownloadComplete()
WebBrowser1.Silent = True
End Sub

Private Sub Form_Load()
WebBrowser1.Silent = True '这样就可以屏蔽了。。
End Sub

'而不是在设计中选中Webbrowser1控件把silent设为true,一定要代码写在form_load中

Tags: vb webbrowser

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 7691

 广告位

↑返回顶部↑