亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 C# 中顯示網頁

在 C# 中顯示網頁

C#
慕容708150 2022-01-09 15:29:08
我想在我的 C# 項目的 Windows 窗體中顯示網頁:http : //vhg.cmp.uea.ac.uk/tech/jas/vhg2018/WebGLAv.html。我在其中使用 WebBrowser 工具并編寫此代碼以在表單中顯示此網頁:webBrowser1.Navigate("http://vhg.cmp.uea.ac.uk/tech/jas/vhg2018/WebGLAv.html");但它沒有顯示完整的網頁!我應該怎么做?
查看完整描述

2 回答

?
婷婷同學_

TA貢獻1844條經驗 獲得超8個贊

默認情況下,Windows 窗體應用程序使用 IE 包裝器,并且不保證使用最新的 IE 版本。閱讀本文以了解 IE 包裝器背后發生的事情以及 Windows 仿真密鑰的作用。


我的一個舊項目中的這段代碼允許以編程方式為您的可執行進程更改 IE 的默認仿真版本:


private static readonly string BrowserEmulationRegistryKeyPath =

            @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";


        /// <summary>

        /// Add the process name to internet explorer emulation key

>       /// i do this because the default IE wrapper dose not support the latest JS features

>       /// Add process to emulation key and set a DWord value (11001) for it means we want use IE.11 as WebBrowser component

        /// </summary>

        public bool EmulateInternetExplorer()

        {

            using (

                var browserEmulationKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationRegistryKeyPath,

                    true))

            {

                if (browserEmulationKey == null)

                    Registry.CurrentUser.CreateSubKey(BrowserEmulationRegistryKeyPath);



                string processName = $"{Process.GetCurrentProcess().ProcessName}.exe";


                // Means emulation already added and we are ready to start

                if (browserEmulationKey?.GetValue(processName) != null)

                    return true;


                // Emulation key not exists and we must add it ( We return false because application restart to take effect of changes )

                if (browserEmulationKey != null)

                {

                    browserEmulationKey.SetValue(processName, 11001, RegistryValueKind.DWord);

                    browserEmulationKey.Flush();

                }

                return false;

            }

        }

如果您的網站無法在最新的 Internet Explorer(不兼容)中正確顯示,您應該使用其他 Web 瀏覽器包裝器,例如在您的 .Net 應用程序中嵌入 Chromium 的 cefSharp。


查看完整回答
反對 回復 2022-01-09
?
GCT1015

TA貢獻1827條經驗 獲得超4個贊

您可以使用 google SDK 瀏覽或使用顯示 html 內容裁判此 鏈接


查看完整回答
反對 回復 2022-01-09
  • 2 回答
  • 0 關注
  • 636 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號