Class Script
The script element is used to embed or reference executable code, typically JavaScript. It can contain inline script code or reference external script files. The script element is commonly used to add interactivity and dynamic behavior to web pages.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionScript()Creates an emptyScriptelement.Creates aScriptelement with the specifiedtype(String)attribute andHtmlElementRawText.text(Object)node. -
Method Summary
Modifier and TypeMethodDescriptionasync attribute.charset attribute.crossorigin(String value) crossorigin attribute.defer attribute.src attribute.type attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElementRawText
getText, setText, textMethods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Script
public Script()Creates an emptyScriptelement. -
Script
Creates aScriptelement with the specifiedtype(String)attribute andHtmlElementRawText.text(Object)node.- Parameters:
type- Thetype(String)attribute. Can benull to unset the attribute.text- The child text node. Can benull to leave the text unset.
-
-
Method Details
-
async
async attribute.Execute script asynchronously.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"async" - Other values - Passed through as-is
-
charset
charset attribute.Specifies the character encoding of the external script resource. This is used when the script is loaded from an external source.
Common values:
"utf-8" - UTF-8 encoding (default)"iso-8859-1" - Latin-1 encoding"windows-1252" - Windows-1252 encoding
- Parameters:
value- The character encoding of the external script resource. Can benull to unset the attribute.- Returns:
- This object.
-
crossorigin
crossorigin attribute.How the element handles cross-origin requests.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
defer
defer attribute.Defer script execution.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"defer" - Other values - Passed through as-is
-
src
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
UriResolvercan be used for values. -
type
type attribute.Type of embedded resource.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-