【问题标题】:How do I display specific sections of multiple web pages on a web page? [duplicate]如何在一个网页上显示多个网页的特定部分? [复制]
【发布时间】:2019-09-13 21:14:54
【问题描述】:

我有一些网页,我只需要在其中显示图表。如何使用 iframe 将它们全部显示在一个页面中?

【问题讨论】:

  • 通常你不会,其他服务器控制页面内容。您可以尝试编写脚本页面来获取其他站点的页面,抓取并解析它,然后显示该缩减版本。如果您这样做,如果您的服务器最终被其他站点的防火墙阻止,请不要感到惊讶。
  • 所有页面都在我自己的域中。

标签: javascript iframe


【解决方案1】:

您无法使用 iframe 加载页面的一部分。您可以使用 JavaScript 库 jQuery 加载页面的特定部分。

例子:

jQuery('#where-you-want-to-load-the-content').load('http://www.example.com/your-page.php #section-you-want-to-bring-in');

解释一下:#where-you-want-to-load-the-content 代表页面上的某个 ID,例如 <div id="where-you-want-to-load-the-content"></div>#section-you-want-to-bring-in 是您要引入的页面部分的 HTML 包装器。

例子:

<div id="section-you-want-to-bring-in">Hello!</div> 将被带入您的代码部分<div id="where-you-want-to-load-the-content"></div>

【讨论】:

    猜你喜欢
    • 2013-07-26
    • 1970-01-01
    • 1970-01-01
    • 2012-07-26
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多