【问题标题】:How to load html in <iFrame>如何在 <iFrame> 中加载 html
【发布时间】:2011-02-14 08:55:43
【问题描述】:

我将我网站的错误页面的 html 存储在 sql 表中,我想在管理端的窗口中显示它们,但无法在 iframe 中加载保存的 html,我使用的是 asp.net mvc2。

需要保存页面,稍后显示给管理员。

请给我正确的方向。

谢谢。

【问题讨论】:

  • 请提供更多背景信息并告诉我们您已经尝试过什么。简单地寻求解决方案通常是不够的(也不应该)。
  • 我试过 jquery $("#iframeid").html('') 问题很简单,我想将保存的 html 加载到 iframe 中。
  • @user310657:你为什么不直接下载到div?为什么是 iframe? iframe 显示在 src 属性中指定的 url 的内容。

标签: javascript asp.net-mvc iframe asp.net-mvc-2


【解决方案1】:

如果您想在 iframe 中使用它,只需编写一个服务器端脚本,该脚本采用此 HTML 并将其动态包装在 HTML 文档中:....等。使此脚本公开可见并传递一些参数来告诉它要显示的内容:

http://www.foo.com/iframescript.asp?html_display_params=saved_html

然后:

<iframe src="http://www.foo.com/iframescript.... 

or: $('#iframeid').attr('src', 'http://www.foo.com/iframescript.asp....

你明白了....

iframe 表示另一个 url 位置,如果你想在 iframe 中查看某些内容,它必须是它自己的页面.....

否则你想要一个正常的框架。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-29
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-14
    • 2018-01-16
    • 2019-08-13
    相关资源
    最近更新 更多