Class Iframe


@Marshalled(typeName="iframe") public class Iframe extends HtmlElementMixed<Iframe>
DTO for an HTML <iframe> element.

The iframe element represents a nested browsing context, embedding another HTML page into the current page. It is commonly used to embed external content such as videos, maps, or other web applications. The sandbox attribute can be used to restrict the capabilities of the embedded content for security purposes.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple iframe embedding external content Iframe iframe1 = iframe() .src("https://example.com/embed") .width("800") .height("600"); // Iframe with sandbox restrictions Iframe iframe2 = iframe() .src("https://example.com/untrusted") .sandbox("allow-scripts allow-same-origin") .width("400") .height("300"); // Iframe with inline content Iframe iframe3 = iframe() .srcdoc("<h1>Inline Content</h1><p>This content is embedded directly.</p>") .width("500") .height("200"); // Iframe with name for targeting Iframe iframe4 = iframe() .name("contentFrame") .src("https://example.com/content") .width("100%") .height("400");

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

    • Iframe

      public Iframe()
      Creates an empty Iframe element.
    • Iframe

      public Iframe(Object... children)
      Creates an Iframe element with the specified child nodes.
      Parameters:
      children - The child nodes. Must not be null.
  • Method Details

    • height

      public Iframe height(Object value)
      height attribute.

      Vertical dimension.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • name

      public Iframe name(String value)
      name attribute.

      Specifies the name of the iframe. This name can be used as the target for links and forms, allowing content to be loaded into the iframe.

      The name should be unique within the document.

      Parameters:
      value - The name of the iframe for targeting. Can be null to unset the attribute.
      Returns:
      This object.
    • sandbox

      public Iframe sandbox(String value)
      sandbox attribute.

      Specifies security restrictions for the iframe content. Multiple restrictions can be specified as a space-separated list.

      Common values:

      • "allow-scripts" - Allow JavaScript execution
      • "allow-same-origin" - Allow same-origin requests
      • "allow-forms" - Allow form submission
      • "allow-popups" - Allow popup windows
      • "allow-top-navigation" - Allow navigation of top-level browsing context
      Parameters:
      value - Security restrictions for the iframe content. Can be null to unset the attribute.
      Returns:
      This object.
    • src

      public Iframe src(Object value)
      src attribute.

      Address of the resource.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      value - The new value for this attribute. Typically a URL or String. Can be null, in which case the attribute is stored with a null value (not removed).
      Returns:
      This object.
    • srcdoc

      public Iframe srcdoc(String value)
      srcdoc attribute.

      Specifies the HTML content to be displayed in the iframe. This content is rendered directly within the iframe without requiring a separate HTTP request.

      The content should be valid HTML that will be displayed in the iframe.

      Parameters:
      value - The HTML content to display in the iframe. Can be null to unset the attribute.
      Returns:
      This object.
    • width

      public Iframe width(Object value)
      width attribute.

      Horizontal dimension.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.