Windows Mobile 6.5 Professional

我是研究僧i 提交于 2019-11-28 10:39:45

问题


I have a problem with windows mobile 6.5 professional. Developed an application that runs on windows mobile 6.5 classic, opening a website from webbrowser. In Professional website works correctly in IE, but not working javascript / jquery in my application with webbrowser. I found it strange the contents of the request agent (Request.UserAgent) from the Professional: Mozilla/4.0 (compatible, MSIE 6.0, Windows CE; IEMobile 7:11)

When the Classic appears the following result:

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


回答1:


I recently stumbled upon the same issue. JavaScript works in IE but not in my C# webbrowser component.

The solution was to check HKLM\Security\Internet Explorer\MSHTML registry key. It must be 0 to allow javascript inside webbrowser! Now my code checks and changes this reg key to zero (if not alreday 0) and then calls InitializeComponents().

The key will change the behaviour of the webbrowser in another way too: the arrow keys now do not move the focus from link to link but they scroll the webbrowser view.

Hope that helps you too.

EDIT: here is a code sample:

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


来源:https://stackoverflow.com/questions/17238382/windows-mobile-6-5-professional

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!