![](/img/trans.png)
[英]Windows Mobile Appliacation works in Professional 6.5 Emulator but not in WM 6.5 Device
[英]Windows Mobile 6.5 Professional
我对Windows Mobile 6.5 Professional有问题。 开发了在Windows Mobile 6.5 classic上运行的应用程序,并从webbrowser打开了一个网站。 在专业网站中,IE可以正常工作,但在使用webbrowser的应用程序中无法正常运行javascript / jquery。 我发现来自Professional的请求代理(Request.UserAgent)的内容很奇怪:Mozilla / 4.0(兼容,MSIE 6.0,Windows CE; IEMobile 7:11)
当经典出现以下结果时:
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注册表项。 它必须为0才能在浏览器中允许javascript! 现在,我的代码检查并将此reg密钥更改为零(如果不是今天为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;
}
}
/// <summary>
/// check and change MSHTML rendering engine
/// </summary>
/// <param name="iVal">0 = use new IE6 engine, enable JavaScript
/// 1 = use old PIE engine</param>
/// <returns></returns>
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;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.