Tag HTML <iframe>

  • Poprzednia strona <i>
  • Następna strona <img>

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>

Try it yourself

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>

Try it yourself

Attribute

Attribute Value Description
allow Specify the functional policy of the <iframe>.
allowfullscreen
  • true
  • false
Set to true if the <iframe> can be activated in full-screen mode by calling the requestFullscreen() method.
allowpaymentrequest
  • true
  • false
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
  • eager
  • lazy
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
  • no-referrer
  • no-referrer-when-downgrade
  • origin
  • origin-when-cross-origin
  • same-origin
  • strict-origin-when-cross-origin
  • unsafe-url
Specify the reference information to be sent when fetching the iframe.
sandbox
  • allow-forms
  • allow-pointer-lock
  • allow-popups
  • allow-same-origin
  • allow-scripts
  • allow-top-navigation
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
  • Poprzednia strona <i>
  • Następna strona <img>