1

Browserコントロールでオンライン支払いゲートウェイをホストする必要があり、が正しく適用されない、またはまったく適用されないFramework 4.5という問題に遭遇しました。CSS

ここですべてのオプションを試してみましたが、うまくいきませんでした。ここNavigateで詳しく説明されているオーバーライドを使用しようとしましたが、ページは適切にレンダリングされますが、新しいブラウザー ウィンドウにポップされます。

browser.Navigate(url, "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">");

私がやろうとしているwebserviceのは、ユーザーがクリックしたコントロールに応じていくつかの呼び出しを行うことです。そのため、MouseDownイベントを利用しました。

またWPF、運が悪いアプリを試して、Browserコントロールが異なるかどうかを確認しました。

支払いゲートウェイの担当者が CSS を提供して手動で適用できるかどうかを確認するのを待っていますが、それまでの間、他の提案はありますか?

**** アップデート ****

以下の提案を試してみましたが、うまくいきませんでした。

また、このInternet Explorer Local Machine Zone Lockdownを試して、違いがあるかどうかを確認しました。

***** さらなるアップデート ***** このサイトの証明書について次のエラーが表示されます。

証明書エラー

AddEventまた、サポートされていないことを知らせる JavaScript エラーも表示されます。これはブラウザのエミュレーションの失敗なのだろうか?

別のアップデート

上記に関して、私は Noseratio の優れたアドバイスに従い、以下を追加しました。

SetBrowserFeatureControlKey("FEATURE_WARN_ON_SEC_CERT_REV_FAILED", fileName, 0); 

この機能は、WebBrowser コントロールをホストするアプリケーションではサポートされていません。

4

1 に答える 1

3

通常、実装FEATURE_BROWSER_EMULATIONするとこのような問題が解決しますが、すでに解決したとおっしゃっていました。独自の HTML+CSS で試してみたい場合は、テスト アプリを共有できます。

using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WbTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            SetBrowserFeatureControl();
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DoNavigationAsync().ContinueWith(_ =>
            {
                MessageBox.Show("Navigation complete!");
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }

        private async Task DoNavigationAsync()
        {
            TaskCompletionSource<bool> documentCompleteTcs = null;

            WebBrowserDocumentCompletedEventHandler handler = delegate 
            {
                if (documentCompleteTcs.Task.IsCompleted)
                    return;
                documentCompleteTcs.SetResult(true);
            };

            documentCompleteTcs = new TaskCompletionSource<bool>();
            this.wb.DocumentCompleted += handler;

            // could do this.wb.Navigate(url) here 
            this.wb.DocumentText = "<!DOCTYPE html><head><meta http-equiv='X-UA-Compatible' content='IE=edge'/></head>"+
                "<body><input size=50 type='text' placeholder='HTML5 if this placeholder is visible'/></body>";

            await documentCompleteTcs.Task;
            this.wb.DocumentCompleted -= handler;

            dynamic document = this.wb.Document.DomDocument;
            dynamic navigator = document.parentWindow.navigator;
            var info =
                "\n navigator.userAgent: " + navigator.userAgent +
                "\n navigator.appName: " + navigator.appName +
                "\n document.documentMode: " + document.documentMode +
                "\n document.compatMode: " + document.compatMode;

            MessageBox.Show(info);
        }

        private static void SetBrowserFeatureControl()
        {
            // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

            // WebBrowser Feature Control settings are per-process
            var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

            // make the control is not running inside Visual Studio Designer
            if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
                return;

            SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); 
        }

        private static void SetBrowserFeatureControlKey(string feature, string appName, uint value)
        {
            using (var key = Registry.CurrentUser.CreateSubKey(
                String.Concat(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\", feature),
                RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
            }
        }

        private static UInt32 GetBrowserEmulationMode()
        {
            int browserVersion = 7;
            using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer",
                RegistryKeyPermissionCheck.ReadSubTree,
                System.Security.AccessControl.RegistryRights.QueryValues))
            {
                var version = ieKey.GetValue("svcVersion");
                if (null == version)
                {
                    version = ieKey.GetValue("Version");
                    if (null == version)
                        throw new ApplicationException("Microsoft Internet Explorer is required!");
                }
                int.TryParse(version.ToString().Split('.')[0], out browserVersion);
            }

            // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
            UInt32 mode = 10000; 

            switch (browserVersion)
            {
                case 7:
                    // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
                    mode = 7000;                     
                    break;
                case 8:
                    // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
                    mode = 8000; 
                    break;
                case 9:
                    // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                    mode = 9000; 
                    break;
                default:
                    // use IE10 mode by default
                    break;
            }

            return mode;
        }
    }
}

まず、そのまま試してみると、次のように表示されるはずです。

ここに画像の説明を入力

documentModecompatMode値は、HTML5 標準モードに対応しています。次に、HTML で試してみて、同じままかどうかを確認してください。

于 2013-09-03T02:20:31.307 に答える