【问题标题】:Windows Mobile 6.5 ProfessionalWindows Mobile 6.5 专业版
【发布时间】:2013-06-21 14:58:01
【问题描述】:

我在使用 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)

当经典出现时,结果如下:

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

【问题讨论】:

  • 欢迎来到 StackOverflow。好吧,您已将标签信息放在主题行中(您不应该这样做 - 它属于标签),并且似乎忘记了提问。 :-) 您能否edit您的帖子并将主题行更改为更有意义的内容,并澄清问题并问我们一个我们可以回答的问题?谢谢。
  • @RafaelTriani 究竟是什么不起作用。如果它的代码,那么我们需要代码。
  • @Ramhound 当我使用 webbrowser 运行我的应用程序时,不要在网站上执行 javascript / jquery。

标签: c# windows-mobile-6.5


【解决方案1】:

我最近偶然发现了同样的问题。 JavaScript 在 IE 中有效,但在我的 C# webbrowser 组件中无效。

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

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

希望对你也有帮助。

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

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;
    }
    }
}

【讨论】:

  • Josef 您可以发布一个示例,说明如何在 C# 中执行此操作?我开始在 Windows Mobile 上编程几天,并没有太多经验。 Ty 为你评论并帮助我。
猜你喜欢
  • 1970-01-01
  • 2013-09-01
  • 2011-06-21
  • 2012-07-29
  • 2014-11-21
  • 1970-01-01
  • 2017-01-28
  • 2012-05-20
  • 2017-06-03
相关资源
最近更新 更多