简体   繁体   English

页面内容中的HTML Iframe

[英]HTML Iframe within page content

I have a huge content in an HTML page and i want to put the same within iframe. 我在HTML页面中有大量内容,我想在iframe中添加相同的内容。 But putting the content within iframe tag within page, page shows that part as blank. 但是将内容放在页面内的iframe标签中,页面将该部分显示为空白。 Please suggest how does we put content within iframe in the same HTML. 请建议我们如何在iframe中将内容放在同一个HTML中。 What should be placed in src if applying the same page content. 如果应用相同的页面内容,应该在src中放置什么。

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

Thanks. 谢谢。

I strongly recommend that if you want to place a large section of your current page's output into a scrollable area of your page, don't use an iframe, instead do something like this: 我强烈建议您如果要将当前页面输出的大部分放在页面的可滚动区域中,请不要使用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>

Of course you can change the height and width of the div to suit your needs. 当然,您可以根据需要更改div的高度和宽度。

the div style="overflow-y: auto;" div style =“overflow-y:auto;” with a specified width and height should (I think) create a scrollable area in your page similar to the output of an iframe, but without requiring the browser to load two copies of the contents. 具有指定的宽度和高度应该(我认为)在页面中创建一个类似于iframe输出的可滚动区域,但不要求浏览器加载内容的两个副本。 Also you avoid the possibility of an infinite loop. 你也避免了无限循环的可能性。

you could also add a border around the area if you like, for example after height: 400px; 如果你愿意,你也可以在该区域周围添加边框,例如在高度:400px之后; by changing the first line to this: 通过将第一行更改为:

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

You would put the link to the page you need to display the content from 您可以将链接放到显示内容所需的页面

<iframe src="http://www.yoursite.com"></iframe>

src = URL potentially surrounded by spaces Gives the address of a page that the nested browsing context is to contain. src =可能由空格包围的URL提供嵌套浏览上下文要包含的页面的地址。

read up on iframes 阅读iframe

Say for example all of your HTML is inside index.html, simply set the src attribute to index.html . 比如说你的所有HTML都在index.html中,只需将src属性设置为index.html

Like so: 像这样:

<iframe src="index.html"></iframe>

Remember, this doesn't necessarily work correctly as you'll run the <iframe> into a continuous loop. 请记住,这不一定正常,因为您将<iframe>运行到连续循环中。 Though, correct me if I'm wrong, it will only repeat the iframe twice as a security policy. 但是,如果我错了,请纠正我,它只会重复iframe两次作为安全策略。

<iframe src="URL or pagename.html"></iframe>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM