zoukankan      html  css  js  c++  java
  • WinForm WebBrowser 设置IE版本

    public enum IeVersion 
    {
        IE7 = 7,
        IE8 = 8,
        IE9 = 9,
        IE10 = 10,
        IE11 = 11
    }; 
    
    /// <summary>  
    /// 修改注册表信息来兼容当前程序
    /// </summary>  
    public static void SetWebBrowserFeatures(IeVersion ieVersion)
    {
        if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) return;
        //获取程序及名称  
        string AppName = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
    
        //得到浏览器的模式的值  
        UInt32 ieMode = GeoEmulationModee((int)ieVersion);
    
        string featureControlRegKey = @"HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControl";
        //设置浏览器对应用程序(appName)以什么模式(ieMode)运行  
    
        Registry.SetValue(featureControlRegKey + "FEATURE_BROWSER_EMULATION", AppName, ieMode, RegistryValueKind.DWord);
     
        Registry.SetValue(featureControlRegKey + "FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", AppName, 1, RegistryValueKind.DWord);
        Registry.SetValue(featureControlRegKey + "FEATURE_AJAX_CONNECTIONEVENTS", AppName, 1, RegistryValueKind.DWord);
        Registry.SetValue(featureControlRegKey + "FEATURE_GPU_RENDERING", AppName, 1, RegistryValueKind.DWord);
        Registry.SetValue(featureControlRegKey + "FEATURE_WEBOC_DOCUMENT_ZOOM", AppName, 1, RegistryValueKind.DWord);
        Registry.SetValue(featureControlRegKey + "FEATURE_NINPUT_LEGACYMODE", AppName, 0, RegistryValueKind.DWord);
    }
    
    /// <summary>  
    /// 通过版本得到浏览器模式的值  
    /// </summary>  
    /// <param name="browserVersion"></param>  
    /// <returns></returns>  
    private static UInt32 GeoEmulationModee(int browserVersion)
    {
        UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode.   
        switch (browserVersion)
        {
            case 7:
                mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.   
                break;
            case 8:
                mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.   
                break;
            case 9:
                mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.                      
                break;
            case 10:
                mode = 10000; // Internet Explorer 10.  
                break;
            case 11:
                mode = 11000; // Internet Explorer 11  
                break;
        }
        return mode;
    }
  • 相关阅读:
    Vue.Draggable实现拖拽效果(快速使用)
    1.从面向过程到面向对象的过渡
    微信支付流程
    2.js原型的基本概念
    POST和GET请求的区别
    vue-router2.0
    vue列表渲染,以及鼠标点击改变样式的问题
    复杂数组结构的深拷贝
    高德地图将字符串地址转为经纬度的一个demo
    数组对象排序
  • 原文地址:https://www.cnblogs.com/flamegreat/p/12195829.html
Copyright © 2011-2022 走看看