问题
What is an iframe, and how is it used in html?
回答1:
An iframe is an object that allows you to embed external content in your HTML page. You can use it to display other web pages, documents (e.g. PDF) etc (although for complex media types you may want to try the object tag instead).
You can add an iframe to your page like so:
<iframe src ="externalContent.html" width="400" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
The p tag inside will display if iframes are not supported by the browser being used.
回答2:
The iframe element denotes an inline frame, simple as that.
Example usage:
<iframe src="foo.html">
<p>Your browser does not support <code>iframe</code> elements.</p>
</iframe>
回答3:
Example of iframe - https://jsfiddle.net/vsaurabhaec/jsgbncf0/
Example with url :
<iframe src="https://www.findertoday.com/address-finder/address/Bhagatpur+Tea+Garden-9953?width=500&access_method=findertoday" target="_parent" width="500" height="270" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
Example with content :
<iframe id="FileFrame" src="about:blank">
<html><body>test</body></html>
</iframe>
NB : iframe need some security awareness. css and js does not have control over inner part of iframe and this is advantage of iframe ( some time )
来源:https://stackoverflow.com/questions/2979860/how-are-iframes-used-in-html