Class NoScript

All Implemented Interfaces:
HeadElement

public class NoScript extends StyledContainerElement<NoScript> implements HeadElement
Represents an HTML <noscript> element that provides alternative content for scripts.

The <noscript> element defines content to be displayed when JavaScript is disabled in the user's browser or when the browser does not support scripting. This element helps ensure graceful degradation for users without JavaScript support.

Features:

  • Displays content only when JavaScript is disabled or unavailable
  • Provides fallback content for script-dependent features
  • Can contain any HTML elements allowed in its parent context
  • Useful for accessibility and progressive enhancement
  • ID attribute excluded by default
  • Supports both head and body placement

Usage:


 // Basic noscript message
 NoScript warning = new NoScript();
 Paragraph message = new Paragraph("JavaScript is required for this page.");
 warning.addElement(message);

 // Alternative navigation
 NoScript nav = new NoScript();
 nav.addElement(new Paragraph("Please enable JavaScript or use these links:"));
 UnorderedList links = new UnorderedList();
 links.addItem(new Anchor("/page1.html", "Page 1"));
 links.addItem(new Anchor("/page2.html", "Page 2"));
 nav.addElement(links);

 // Meta refresh fallback
 NoScript refresh = new NoScript();
 Meta meta = new Meta();
 meta.setHttpEquiv("refresh");
 meta.setContent("0; url=/no-js.html");
 refresh.addElement(meta);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • NoScript

      public NoScript()
      Constructs a new NoScript element.

      Creates an HTML <noscript> element with ID attribute excluded. Content added to this element will only be visible when JavaScript is disabled or unavailable in the user's browser.