【问题标题】:Display a webpage via an iframe通过 iframe 显示网页
【发布时间】:2012-09-13 17:42:40
【问题描述】:

我正在寻找创建一个非常简单的程序,它的唯一功能是显示我的网站。所以基本上该程序就像网站的 iframe。实现这一目标的最佳方法是什么?

【问题讨论】:

  • 这与 C++ 或 C# 有什么关系?
  • 我认为因为我需要它成为一个独立的 Windows 程序,所以它需要用 C++/C# 等真实语言进行编码
  • 为什么不让他们使用自己的网络浏览器?

标签: c# c++ iframe


【解决方案1】:

您不能使用 iFrame,因为它是一种浏览器技术。我相信您必须使用以下网络浏览器:

using System;
using System.Windows.Forms;

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

    private void Form1_Load(object sender, EventArgs e)
    {
        // When the form loads, open this web page.
        webBrowser1.Navigate("http://www.dotnetperls.com/");
    }

    private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
        // While the page has not yet loaded, set the text.
        this.Text = "Navigating";
    }

    private void webBrowser1_DocumentCompleted(object sender,
        WebBrowserDocumentCompletedEventArgs e)
    {
        // Better use the e parameter to get the url.
        // ... This makes the method more generic and reusable.
        this.Text = e.Url.ToString() + " loaded";
    }
    }
}

参考。 http://www.dotnetperls.com/webbrowser

注意:示例在 C# 中。

检查一下 C++ What embedded browser for C++ project?

【讨论】:

  • 哇,非常感谢您这么快的回复!!顺便问一下,它是在默认浏览器还是 IE 中启动网站?
  • 它将加载到form1中的Web浏览器控件中。
  • 感谢Randolf 的解释,我不是程序员! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多