.net 里的Webbowser控件默认情况是用IE7来渲染

可修改注册表试用是最新的版本来渲染:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using Microsoft.Win32;
using System.IO; namespace wgscd
{ public enum BrowserEmulationVersion
{
Default = 0,
Version7 = 7000,
Version8 = 8000,
Version8Standards = 8888,
Version9 = 9000,
Version9Standards = 9999,
Version10 = 10000,
Version10Standards = 10001,
Version11 = 11000,
Version11Edge = 11001
}
public static class WBEmulator
{
private const string InternetExplorerRootKey = @"Software\Microsoft\Internet Explorer"; public static int GetInternetExplorerMajorVersion()
{
int result; result = 0; try
{
RegistryKey key; key = Registry.LocalMachine.OpenSubKey(InternetExplorerRootKey); if (key != null)
{
object value; value = key.GetValue("svcVersion", null) ?? key.GetValue("Version", null); if (value != null)
{
string version;
int separator; version = value.ToString();
separator = version.IndexOf('.');
if (separator != -1)
{
int.TryParse(version.Substring(0, separator), out result);
}
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
}
private const string BrowserEmulationKey = InternetExplorerRootKey + @"\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; public static BrowserEmulationVersion GetBrowserEmulationVersion()
{
BrowserEmulationVersion result; result = BrowserEmulationVersion.Default; try
{
RegistryKey key; key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
if (key != null)
{
string programName;
object value; programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
value = key.GetValue(programName, null); if (value != null)
{
result = (BrowserEmulationVersion)Convert.ToInt32(value);
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
}
public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
{
bool result; result = false; try
{
RegistryKey key; key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); if (key != null)
{
string programName; programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); if (browserEmulationVersion != BrowserEmulationVersion.Default)
{
// if it's a valid value, update or create the value
key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
}
else
{
// otherwise, remove the existing value
key.DeleteValue(programName, false);
} result = true;
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
} public static bool SetBrowserEmulationVersion()
{
int ieVersion;
BrowserEmulationVersion emulationCode; ieVersion = GetInternetExplorerMajorVersion(); if (ieVersion >= 11)
{
emulationCode = BrowserEmulationVersion.Version11;
}
else
{
switch (ieVersion)
{
case 10:
emulationCode = BrowserEmulationVersion.Version10;
break;
case 9:
emulationCode = BrowserEmulationVersion.Version9;
break;
case 8:
emulationCode = BrowserEmulationVersion.Version8;
break;
default:
emulationCode = BrowserEmulationVersion.Version7;
break;
}
} return SetBrowserEmulationVersion(emulationCode);
}
public static bool IsBrowserEmulationSet()
{
return GetBrowserEmulationVersion() != BrowserEmulationVersion.Default;
} } /*
调用 :
* if (!WBEmulator.IsBrowserEmulationSet())
{
WBEmulator.SetBrowserEmulationVersion();
}
*/ }

  

或者使用第三方的浏览器控件:

项目基于WebKit.NET 0.5开发
google code地址:https://code.google.com/archive/p/open-webkit-sharp/
github网址 : https://github.com/Erls-Corporation/open-webkit-sharp

use the WebKit.NET :https://sourceforge.net/projects/webkitdotnet/

.net 设置Webbowser 版本的更多相关文章

  1. Composer设置忽略版本匹配的方法

    Composer简介 Composer 是 PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们.Composer 不是一个包管理器.是的,它涉及 "pa ...

  2. PHP集成环境自定义设置PHP版本,同时运行多个php版本,700个PHP版本随时切换,一键开启常用模块。

    本文采用我自己开发的纯绿色版WAMP环境(我将这个WAMP环境命名为PHPWAMP) (PHPWAMP默认集成VC,不需要单独安装) 那么什么是WAMP环境?WAMP这个词是什么意思? Windows ...

  3. composer设置忽略版本匹配

    composer install 时遇到错误: Your requirements could not be resolved to an installable set of packages. 原 ...

  4. GreenDao设置数据版本

    GreenDao设置数据库版本增加后,会自动删除并创建新数据库,将SCHEMA_VERSION增加即可. 在3.0里可以在config配置里进行设置 apply plugin: 'com.androi ...

  5. PyCharm设置Python版本

    PyCharm默认会使用虚拟的Python解释器,即使没有安装也能够运行Python代码,但有强迫症的程序员一定不能忍受Project中存在这么多的文件目录 设置Python版本 File->S ...

  6. 解决java.io.IOException: Cannot run program "javac"问题,并设置jdk版本

    原因:没有配置java路径 解决方法:设置java_home路径 设置jdk版本是10的方法:在sbt文件中添加一行: javacOptions := Seq(") 然后重新执行命令:sbt ...

  7. C#程序集系列08,设置程序集版本

    区别一个程序集,不仅仅是程序集名称,还包括程序集版本.程序集公匙.程序集文化等,本篇体验通过界面和编码设置程序集版本. □ 通过Visual Studio设置程序集版本 →右键项目,选择"属 ...

  8. PyCharm设置Python版本,你肯定不知道!

      前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:智小星    PyCharm默认会使用虚拟的Python解释器,即使 ...

  9. eclipse配置JDK和设置编译版本的几种方法

    eclipse配置JDK和设置编译版本的几种方法  2016-12-13 16:08             http://blog.csdn.net/gnail_oug/article/detail ...

随机推荐

  1. [我的阿里云服务器] —— WorkPress

    前言: WordPress是基于PHP和MYSQL编成的一套博客系统,因此一般会选择LAMP环境来让它最稳定地运行, 这里的LAMP指的是Linux.Apache.MySQL.PHP,我们我的阿里云服 ...

  2. CSS 实例之打开大门

    本个实例主要的效果如下图所示 本案例主要运用到了3D旋转和定位技术.具体步骤如下: 1.首先在页面主体加三个很简单的div标签: <div class="door"> ...

  3. Chained Declustering

          此论文描述了在无共享架构的多处理器机器上的数据库系统的数据冗余分布方法.该方法提高了系统的可用性,同时在单节点故障的情况下,可以很好的实现负载均衡.以下是论文的一些摘要,详细可以参见论文原 ...

  4. Azure 托管镜像和非托管镜像对比

    目前中国区 Azure 也已经可以使用命令制作托管镜像了.但对于托管镜像和非托管镜像,就像托管磁盘和非托管磁盘一样,很多人可能一开始无法理解.这里就此进行了一个简单对比: 通过对比测试,这里总结了这两 ...

  5. 解决JBoss只能通过localhost访问不能通过IP的问题

    前序 现在EJB是真的有点落伍了么,网上找点资料都挺难的样子,而且都是很久的了..好吧,最近对EJB有点兴趣学习一下,结果下载到服务器启动后,居然不能直接通过服务器IP访问,也是醉了,默认只能通过本地 ...

  6. TCP的socket资源被耗尽的问题

    一. 故障现象 部分机顶盒用户出现大面积登录APP时,界面停留在登陆页面,无反应. 二. 现象初步分析 本次问题出现时,所有AAA出现了异常流量波动,在AAA异常流量段期间接到用户故障报障.此时主要表 ...

  7. Qt简介 及与MFC、GDK+的比较

    Qt C++图形用户界面应用程序开发框架. Qt的由来和发展 1.QT由来 Haavard Nord 和Eirik Chambe-Eng于1991年开始开发"Qt",1994年3月 ...

  8. Python编写API接口

    要求通过http://192.168.50.74/aptest/calc/?a=aa&c=00&b=bb进行访问,参数a="aa",b="bb" ...

  9. JAVA JComboBox的监听事件(ActionListener、ItemListener)

    版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   参考资料: http://263229365.iteye.com/blog/1040329 https://www.ja ...

  10. word文档重新打开后文档结构错乱

    word文档重新打开后文档结构错乱,然后通过如下方法解决了. OFFICE2007及以上.        在打开word的时候左下角会有提示word自动更新文档样式,按esc键取消,然后在大纲模式下任 ...