使用WebBrowser控件创建内部浏览器

时间:2018-12-12 03:58:28

标签: c# dialog webbrowser-control

我正在从事一个项目,该项目的一部分是我希望能够在窗口中打开网页。例如:由于出现问题,我打开了一个窗口。有一个“了解更多”按钮。单击后,它将打开一个带有WebBrowser控件的对话框,并显示一个帮助网站。

这是实际发生的情况:单击按钮,打开对话框,WebBrowser不执行任何操作。这是我的代码:

String html = "<h1>Please wait</h1>"
+ "<p>We are loading your help document...</p>"
+ "<p>Still having problems? Contact us!</p><br />"
+ "<p>awesometech1000@gmail.com</p>";
// + "<script>"
// + " window.location.href = '" + "https://example.com" + "'; 
</script>";

BrowserDialog dialog = new BrowserDialog();
dialog.Browser.Navigate("about:blank");
dialog.Browser.Document.OpenNew(false);
dialog.Browser.Document.Write(html);
dialog.Browser.Refresh();

在另一个窗口中,我有以下代码:

Uri learnMoreSite = new Uri("https://gameonpower.weebly.com/cookie");
BrowserDialog.SetSite( learnMoreSite );
BrowserDialog cl = new BrowserDialog();
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (cl.ShowDialog() == DialogResult.OK)
{

}

应该怎么办,我可以更改WebBrowser中显示的网站。然而,那没有发生。发生了什么事?

0 个答案:

没有答案