Class Body


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

The body element represents the content of an HTML document. It contains all the visible content of the page, including text, images, links, forms, and other elements. The body element is typically the direct child of the html element and contains all the main content of the document.

Examples:

// Simple body with text content Body body1 = body().text("Welcome to our website!"); // Body with structured content Body body2 = body() .children( header().children( h1().text("Page Title") ), main().children( p().text("Main content goes here.") ), footer().text("Copyright 2024") ); // Body with event handlers Body body3 = body() .onload("initializePage()") .onbeforeunload("return confirm('Are you sure you want to leave?')") .text("Page content");

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

See Also:
  • Constructor Details

    • Body

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

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

    • onafterprint

      public Body onafterprint(String value)
      onafterprint attribute.

      Event handler for when the document has finished printing.

      Parameters:
      value - JavaScript code to execute when the afterprint event occurs. Can be null to unset the attribute.
      Returns:
      This object.
    • onbeforeunload

      public Body onbeforeunload(String value)
      onbeforeunload attribute.

      Event handler for when the document is about to be unloaded (page refresh, navigation, etc.).

      Parameters:
      value - JavaScript code to execute when the beforeunload event occurs. Can be null to unset the attribute.
      Returns:
      This object.
    • onmessage

      public Body onmessage(String value)
      onmessage attribute.

      Event handler for when a message is received from another window or worker.

      Parameters:
      value - JavaScript code to execute when the message event occurs. Can be null to unset the attribute.
      Returns:
      This object.
    • ononline

      public Body ononline(String value)
      ononline attribute.

      Event handler for when the browser has gone online.

      Parameters:
      value - JavaScript code to execute when the online event occurs. Can be null to unset the attribute.
      Returns:
      This object.
    • onpageshow

      public Body onpageshow(String value)
      onpageshow attribute.

      Event handler for when the page is displayed (including when returning from back/forward cache).

      Parameters:
      value - JavaScript code to execute when the pageshow event occurs. Can be null to unset the attribute.
      Returns:
      This object.
    • onstorage

      public Body onstorage(String value)
      onstorage attribute.

      Event handler for when the storage area (localStorage or sessionStorage) is modified.

      Parameters:
      value - JavaScript code to execute when the storage event occurs. Can be null to unset the attribute.
      Returns:
      This object.