.net 设置Webbowser 版本
.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 版本的更多相关文章
- Composer设置忽略版本匹配的方法
Composer简介 Composer 是 PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们.Composer 不是一个包管理器.是的,它涉及 "pa ...
- PHP集成环境自定义设置PHP版本,同时运行多个php版本,700个PHP版本随时切换,一键开启常用模块。
本文采用我自己开发的纯绿色版WAMP环境(我将这个WAMP环境命名为PHPWAMP) (PHPWAMP默认集成VC,不需要单独安装) 那么什么是WAMP环境?WAMP这个词是什么意思? Windows ...
- composer设置忽略版本匹配
composer install 时遇到错误: Your requirements could not be resolved to an installable set of packages. 原 ...
- GreenDao设置数据版本
GreenDao设置数据库版本增加后,会自动删除并创建新数据库,将SCHEMA_VERSION增加即可. 在3.0里可以在config配置里进行设置 apply plugin: 'com.androi ...
- PyCharm设置Python版本
PyCharm默认会使用虚拟的Python解释器,即使没有安装也能够运行Python代码,但有强迫症的程序员一定不能忍受Project中存在这么多的文件目录 设置Python版本 File->S ...
- 解决java.io.IOException: Cannot run program "javac"问题,并设置jdk版本
原因:没有配置java路径 解决方法:设置java_home路径 设置jdk版本是10的方法:在sbt文件中添加一行: javacOptions := Seq(") 然后重新执行命令:sbt ...
- C#程序集系列08,设置程序集版本
区别一个程序集,不仅仅是程序集名称,还包括程序集版本.程序集公匙.程序集文化等,本篇体验通过界面和编码设置程序集版本. □ 通过Visual Studio设置程序集版本 →右键项目,选择"属 ...
- PyCharm设置Python版本,你肯定不知道!
前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:智小星 PyCharm默认会使用虚拟的Python解释器,即使 ...
- eclipse配置JDK和设置编译版本的几种方法
eclipse配置JDK和设置编译版本的几种方法 2016-12-13 16:08 http://blog.csdn.net/gnail_oug/article/detail ...
随机推荐
- Chrome Extension 实战
想起个问题,线上项目js要有bug,怎么进行调试修改. ------------- 想起来,方法应该是,拦截线上的js的请求,转到本地代码上进行调试... ------------- 网上看到 Chr ...
- Android之编写测试用例
测试是软件工程中一个非常重要的环节,而测试用例又可以显著地提高测试的效率和准确性.测试用例其实就是一段普通的程序代码,通常是带有期望的运行结果的,测试者可以根据最终的运行结果来判断程序是否能正常工作. ...
- 【jdk源码2】Objects源码学习
在学习上一个类TreeMap的时候,提到了这个类,这个类是jdk1.7新增的,里面有很多实用的方法.就是一个工具类,熟悉以后,如果里面有已经实现的方法,那么就不要再去实现了,省时省力省测试. 一.简单 ...
- [WPF 知识总结系列] —— 基本控件的简单样式集合
一.ScrollBar <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presenta ...
- 用sparkR, 分析上亿条订单数据的脚本。
上周我们这个10人的小团队开发的推荐拉新系统, 日拉新人数已接近4万人.过去几个月这个系统从无到有, 拉新从日增几千稳步增长到日增几万, 同事们几个月来,每天工作13个小时以上,洗澡时间都没有, 有时 ...
- Cisco HSRP 配置方法(热备份路由协议)配置实例
转裁于51CTO.http://www.mamicode.com/info-detail-862350.html HSRP----热备份路由协议 思科私有协议,与VRRP 虚拟路由协议 相近,(国际标 ...
- 俄罗斯方块(JS+CSS)
这是一个用 js + css 写的网页版俄罗斯方块. 具体代码与示例可访问我的另一个博客查看,源码与示例.
- Python实例---模拟微信网页登录(day2)
第三步: 实现长轮询访问服务器---day2代码 settings.py """ Django settings for weixin project. Generate ...
- SQL慢查询安装过程
SQL慢查询 基本操作 打开防火墙 firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload 安 ...
- MySQL基础之 日期时间函数
基础日期函数和时间函数 1.CURDATE()函数:返回当前只带有年月日格式的日期 2.CURTIME()函数:返回当前只带有时分秒格式的时间 3.NOW()函数:返回当前日期和时间 4.UNIX_T ...