zoukankan      html  css  js  c++  java
  • WebBrowser引用IE版本问题,更改使用高版本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

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

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

    下面是32位 64位系统需要修改的注册表地址 以及IE各版本的值
    32 bit:
    HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION
    Value Key: yourapplication.exe
    64 bit:
    HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION
    Value Key: yourapplication.exe
    The value to set this key to is (taken from MSDN here) as decimal values:
    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.

  • 相关阅读:
    UML用例图总结
    项目管理心得:一个项目经理的个人体会、经验总结
    UML类图符号简介
    C++中栈和堆上建立对象的区别
    Win32 API
    Python
    remove extra kernel
    Create short cut
    Set Form Position
    Get folder
  • 原文地址:https://www.cnblogs.com/smiler/p/8484487.html
Copyright © 2011-2022 走看看