标签:引擎 load doc main ie7 proc ie11 scope rds
最近做一个WPF触屏的项目,引用到WebBrowser控件,由于是触屏的所以控件里的网页可以缩放,客户提出要求,屏蔽这缩放功能。
于是网上找了很多资料,也换过控件,WebView2 控件使用Microsoft Edge (Chromium)作为呈现引擎。
后来找到一个完美的解决方案,我在这里直接共享出来。
一、设置浏览器仿真
Windows Internet Explorer 8及以后版本。feature_browser_simulation特性定义了Internet Explorer的默认模拟模式,并支持以下值。
11001 (0x2AF9) |
Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks. |
11000 (0x2AF8) |
IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11. |
10001 (0x2711) |
Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive. |
10000 (0x02710) |
Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10. |
9999 (0x270F) |
Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks. |
9000 (0x2328) |
Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9. Important In Internet Explorer 10,Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
|
8888 (0x22B8) |
Webpages are displayed in IE8 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks. |
8000 (0x1F40) |
Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8 Important In Internet Explorer 10,Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
|
7000 (0x1B58) |
Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control. |
1.找到注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
2.添加DWORD(32位)值,重命名为你的程序名,例如QQMusic.exe
3.根据上面对应的数值设置十进制数值;
二、禁用阻塞本地Script脚本
Internet Explorer 7及以后版本。在启用阻塞本地Script脚本特性时,允许存储在本地机器区域的脚本仅在从本地机器区域加载的网页上运行。
该属性默认时启用的(DWORD) 00000001,我们需将他设为禁用(DWORD) 00000000.
1.找到注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BLOCK_LMZ_SCRIPT
2.添加DWORD(32位)值,并重命名
3.修改十进制数值为0
三、禁用传统输入模式
由于微软在Windows 8以上引入了新的输入模式,为了使遗留的应用程序提供最广泛的兼容性,WebBrowser控件在Windows 8以上的系统中会模拟Windows 7鼠标、触摸和笔的输入模式。
传统输入模式启用时:
1.Trident渲染引擎(mshtml.dll)不处理Windows指针消息。
2.文档对象模型(DOM)指针和手势事件不会触发。
3.鼠标和触摸信息按Windows 7输入模式发送。
4.触摸选择遵循Windows 7模式(“拖动至选择”),而不是Windows 8模式(“点击至选择”)。
5.硬件加速平移和缩放被禁用。
6.Zoom和Pan样式属性将会被忽略
第5条和第6条就是导致我不管怎么去改html样式,都无法屏蔽缩放的原因。因为传统输入模式默认是没有开启的,我们只需将他启用,就可以禁用WebBrowser的触屏功能了。
1.找到注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControlFEATURE_NINPUT_LEGACYMOD
2.添加DWORD(32位)值,并重命名
3.修改十进制数值为0
private void SetBrowSerCompatibilityModel() { //获取程序名称 var fileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); if (string.Compare(fileName, "devenv.exe", true) == 0)//确定不是在vs中运行 return; //设置浏览器仿真 using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree)) { key.SetValue(fileName, (uint)10000, RegistryValueKind.DWord); } //禁用阻塞本地Script脚本 using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BLOCK_LMZ_SCRIPT", RegistryKeyPermissionCheck.ReadWriteSubTree)) { key.SetValue(fileName, (uint)0, RegistryValueKind.DWord); } //禁用传统输入模式 using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMOD", RegistryKeyPermissionCheck.ReadWriteSubTree)) { key.SetValue(fileName, (uint)0, RegistryValueKind.DWord); } }
标签:引擎 load doc main ie7 proc ie11 scope rds
原文地址:https://www.cnblogs.com/LenLiin/p/13168825.html