zoukankan      html  css  js  c++  java
  • Winform 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_MACHINESOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION]
    [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION]

      在其中新增一个DWORD值。键值名称写入你的程序名,然后在数值数据填入1f40。也就是IE8

    填写完毕后。到程序目录下打开就可以看到WebBrowser已经引用IE8模式了,这里要主意的是不要在VS打开。

    建议只做本地测试使用。尽量提高网站自身的兼容性才是王道。

    IE各版本的值如下:

    • 11001 (0x2EDF),这俩值不相等!用10进制的11001! Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive

    • 11000 (0x2AF8) :Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode

    • 10000 (0x2710) :Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

    • 10001 (0x2AF7) :Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

    • 9999 (0x270F) :Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.

    • 9000 (0x2328) :Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

    • 8888 (0x22B8) :Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.

    • 8000 (0x1F40) :Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.

    • 7000 (0x1B58) :Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

  • 相关阅读:
    占位
    阳光服务平台-敏捷开发
    两种方法实现带验证码的用户登录
    红警大战JAVA简单版
    JPanel与JFrame的区别
    java中import详解
    敏捷开发
    GitHub:本地项目上传与团队协作
    从结缘计算机到未来规划
    (三)微信小程序首页的分类功能和搜索功能的实现笔记
  • 原文地址:https://www.cnblogs.com/simadi/p/5479278.html
Copyright © 2011-2022 走看看