Tag HTML <iframe>
Definicja i użycie
<iframe>
Tag definiuje framework wewnętrzny (wewnętrzny framework).
Framework wewnętrzny jest używany do wtykania innego dokumentu do bieżącego dokumentu HTML.
Wskazówka:Użyj CSS do ustawienia <iframe>
stylu (zobacz poniższy przykład).
Wskazówka:Najlepiej zawsze używać <iframe>
Zawiera atrybut title. Odczytywarki ekranowe mogą używać tego atrybutu do odczytania informacji o <iframe>
Opis zawartości.
Zobacz również:
Wykład HTML:HTML Iframe
Przeglądarka DOM HTML:Obiekt IFrame
Przykład
Przykład 1
Tag wewnętrzny frameworka wygląda tak:
<iframe src="https://www.codew3c.com" title="CodeW3C.com w Internecie"></iframe>
Example 2
Add and remove the border of the iframe (using CSS):
<iframe src="/index.asp" width="100%" height="300" style="border:1px solid black;"> </iframe> <iframe src="/index.asp" width="100%" height="300" style="border:none;"> </iframe>
Attribute
Attribute | Value | Description |
---|---|---|
allow | Specify the functional policy of the <iframe>. | |
allowfullscreen |
|
Set to true if the <iframe> can be activated in full-screen mode by calling the requestFullscreen() method. |
allowpaymentrequest |
|
Set to true if cross-origin <iframe> calls to the Payment Request API are allowed. |
height | Pixels | Specify the height of the <iframe>. The default height is 150 pixels. |
loading |
|
Specify whether the browser should load the iframe immediately or defer loading until certain conditions are met. |
name | Text | Specify the name of the <iframe>. |
referrerpolicy |
|
Specify the reference information to be sent when fetching the iframe. |
sandbox |
|
Enable a series of additional restrictions on the content of the <iframe>. |
src | URL | Specify the address of the document to be embedded in the <iframe>. |
srcdoc | HTML code | Specify the HTML content of the page to be displayed in the <iframe>. |
width | Pixels | Specify the width of the <iframe>. The default width is 300 pixels. |
Global attributes
<iframe>
Znacznik również obsługuje Globalne atrybuty w HTML.
Atrybuty wydarzeń
<iframe>
Znacznik również obsługuje Atrybuty wydarzeń w HTML.
Domyślne ustawienia CSS
Większość przeglądarek będzie używała następujących domyślnych wartości do wyświetlania <iframe>
Element:
iframe:focus { outline: none; } iframe[seamless] { display: block; }
Obsługa przeglądarek
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Wsparcie | Wsparcie | Wsparcie | Wsparcie | Wsparcie |