Windows Mobile 6.5 Professional

我有一个Windows Mobile 6.5专业版的问题。 开发了一个在windows mobile 6.5 classic上运行的应用程序,从webbrowser打开一个网站。 在专业网站在IE中正常工作,但在我的应用程序与webbrowser不工作javascript / jquery。 我发现来自Professional的请求代理(Request.UserAgent)的内容很奇怪:Mozilla / 4.0(兼容,MSIE 6.0,Windows CE; IEMobile 7:11)

当Classic出现以下结果时:

Mozilla / 4.0(兼容,MSIE 6.0,Windows NT 5.1,Windows Phone 6.5.3.5

我最近偶然发现了同样的问题。 JavaScript适用于IE,但不适用于我的C#webbrowser组件。

解决方案是检查HKLM \ Security \ Internet Explorer \ MSHTML注册表项。 在webbrowser中允许javascript必须为0! 现在我的代码检查并将此reg键更改为零(如果不是alreday 0),然后调用InitializeComponents()。

键也会以另一种方式改变web浏览器的行为:箭头键现在不会将焦点从链接移动到链接,但是它们会滚动Web浏览器视图。

希望对你也有帮助。

编辑:这是一个代码示例:

using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WebBrowser { public partial class Form1 : Form { public Form1() { checkMSHTML(0); InitializeComponent(); webBrowser1.ScriptErrorsSuppressed = false; } private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { switch (e.Button.ImageIndex) { case 0: webBrowser1.Url = new Uri( "http://192.168.128.5/www"); break; case 1: this.Close(); break; } } ///  /// check and change MSHTML rendering engine ///  /// 0 = use new IE6 engine, enable JavaScript /// 1 = use old PIE engine ///  bool checkMSHTML(int iVal) { bool bRet = false; Microsoft.Win32.RegistryKey rKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Security\Internet Explorer",true); if (rKey != null) { int iMSHTML = (int) rKey.GetValue("MSHTML"); if (iMSHTML != iVal) { rKey.SetValue("MSHTML", iVal, Microsoft.Win32.RegistryValueKind.DWord); rKey.Flush(); rKey.Close(); bRet = true; } else { rKey.Close(); bRet = true; } } return bRet; } } }