<ao:script>

Manually establishes a script context when automatic detection is not possible. The body of this tag contains a script.

The script should not be encoded as if in HTML/XML, it must have single "&" instead of "&amp;". The script may contain any characters valid in that language, including <, >, &, \u0000 (null), or any other values.

The script will be properly encoded for the content of this tag. Thus, you may have a script of arbitrary complexity containing arbitrary data within an XHTML onclick attribute, the tags will make sure everything is properly encoded.

The content type of this tag is equal to the type set in the type attribute.

Any attribute that has no namespace and begins with param. is added to the src as a URL parameter. The parameter name is the part of the attribute name following param..

When a parameter value is null it is not added. When a parameter value is an Enum, the value is obtained via Enum.name(). If the value is an Iterable, Iterator, Enumeration, or array, then each non-null element is coerced to String as a separate parameter in iteration order. Otherwise, the value itself is coerced to String for the parameter value.

Nested <ao:param> or <ao:params> tags will add parameters after any provided as attributes.

For simpler scenarios, the following tags are simplier alternatives:

Tag Information

Tag Class: com.aoapps.taglib.ScriptTag
TagExtraInfo Class: com.aoapps.taglib.ScriptTagTEI
Body Content: scriptless
Display Name: None
Dynamic Attributes: true

Attributes

Name Required Evaluation Type Description
id No Runtime String

The id of the element. A nested <ao:id> tag will override this value.

class No Runtime Object

The CSS class for the element. A nested <ao:class> tag will override this value.

dir No Runtime String

The dir of the element. A nested <ao:dir> tag will override this value.

style No Runtime Object

The CSS style for the element. A nested <ao:style> tag will override this value.

type No Runtime Object

Specifies the type of script. The default is application/javascript, also allows text/javascript application/json and application/ld+json. A nested <ao:type> tag will override this value.

src No Runtime String

The src for the script. The src is modified in several ways to make things much easier to work with.

A nested <ao:src> tag will override this value.

In order to make relative paths predictable, relative paths are interpreted from the current JSP page.

In order to keep paths app-relative, if starts with a /, the context path will be prepended to the path.

In order to simplify things behind URL mapping schemes, the src is always written starting with '/'. This avoids any need to include any <ao:base> tags.

URL rewriting is performed as needed via HttpServletResponse.encodeURL.

To support paths in different character sets, a Unicode to ASCII URI encoding is performed on every character that is not defined in RFC 3986: Reserved Characters. To avoid ambiguity, any dynamic parameters or anchors in the URL must have been correctly encoded by the caller.

Any directly nested <ao:param> or <ao:params> tag will add parameters to the src.

absolute No Runtime boolean

When true, generates an absolute URL for the src for the script. Defaults to false.

canonical No Runtime boolean

When true, will generate a Canonical URL. Canonical URLs should be used where per-user response URL rewriting (such as information added when cookies are disabled) should be avoided. Defaults to false.

addLastModified No Runtime String

If the src represents a local resource, a parameter of "lastModified=#####" may be automatically added with the timestamp of the local resource to the nearest second. May be one of true, false, or auto. Defaults to auto.

In auto mode, last modified stamping may be disabled by the client with the X-com-aoapps-servlet-lastmodified-enabled: false header.

In auto mode, last modified stamping is not performed on Canonical URLs.

async No Runtime boolean

When true, loads the script asynchronously. Defaults to false.

defer No Runtime boolean

When true, loads the script deferred. Defaults to false.

onerror No Runtime Object

A JavaScript onerror handler. A nested <ao:onerror> tag will override this value.

onload No Runtime Object

A JavaScript onload handler. A nested <ao:onload> tag will override this value.

Variables

No Variables Defined.