javascript - 页面内容中的 HTML Iframe

标签 javascript php html css user-interface

我在 HTML 页面中有大量内容,我想将其放入 iframe 中。但是将内容放在页面内的 iframe 标记中,页面显示该部分为空白。请建议我们如何将内容放在同一个 HTML 的 iframe 中。如果应用相同的页面内容,应该在src中放置什么。

<iframe src="">
//Content
</iframe>

谢谢。

最佳答案

我强烈建议,如果您想将当前页面的大部分输出放入页面的可滚动区域,请不要使用 iframe,而应执行以下操作:

<div style="overflow-y: auto; width: 100%; height: 400px;">
  <!-- put all of your large amount of content after this comment, before the closing div tag -->
  <p>this is my huge amount of content (just an example.... you'd have hundreds of lines of code here I suspect</p>
</div>

当然,您可以根据需要更改 div 的高度和宽度。

div style="overflow-y: auto;"具有指定的宽度和高度应该(我认为)在您的页面中创建一个类似于 iframe 输出的可滚动区域,但不需要浏览器加载内容的两个副本。您还可以避免无限循环的可能性。

如果您愿意,您还可以在该区域周围添加边框,例如在 height: 400px 之后;通过将第一行更改为:

<div style="overflow-y: auto; width: 100%; height: 400px; border: 2px solid grey;">

关于javascript - 页面内容中的 HTML Iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22767723/

相关文章:

php - Laravel 5 获取数据库前缀

javascript - 如何让 div 框淡入和淡出 div

javascript - 如何切换具有持续时间和显示的 jQuery 元素?

javascript - 如何在 vue 中使用 gettext 翻译文本?

javascript - 如何检查字符串是否包含重复字符?

php - 使用 PHP 中的特定字符串代码将价格转换为字符串

php 和 mysql 实时搜索

javascript - 在 react 中从父dom节点中删除子组件

javascript - 在循环内顺序返回依赖 promise

HTML XPath : Extracting text mixed in with multiple tags?