API Reference
Function
Add-HTMLScript
Adds JavaScript content to the HTML body.
Remarks
This function adds JavaScript content to the HTML body by including JavaScript code from files, strings, or links. It allows customization of the placement of JavaScript content within the HTML document.
Examples
EXAMPLE 1
Add-HTMLScript -Placement 'Header' -Resource 'MyScript' -ResourceComment 'Script for functionality X' -Link 'https://example.com/script.js'
Adds an external JavaScript file 'script.js' to the header of the HTML document with a specified comment.
EXAMPLE 2
Add-HTMLScript -Placement 'Footer' -Resource 'CustomScript' -ResourceComment 'Custom script for feature Y' -Content 'function myFunction() { // code here }'
Adds custom JavaScript content to the footer of the HTML document with a specified comment.
EXAMPLE 3
Add-HTMLScript -Placement 'Inline' -Resource 'InlineScript' -ResourceComment 'Inline script for page Z' -FilePath 'C:\Scripts\inline.js' -ReplaceData @{ 'placeholder' = 'replacement' }
Adds JavaScript code from a file 'inline.js' to be included inline in the HTML document with specified replacements.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Add-HTMLScript [-AddComments] [-Content <String[]>] [-FilePath <String[]>] [-Link <String[]>] [-Placement <Inline|Header|Footer>] [-ReplaceData <IDictionary>] [-Resource <IDictionary>] [-ResourceComment <String>] [-SkipTags] [<CommonParameters>]
#
Parameter set:
All Parameter SetsParameters
- AddComments SwitchParameter
- Indicates whether to add comments around the JavaScript content. By default, comments are not added.
- Content String[]
- Specifies an array of JavaScript content as strings to be included.
- FilePath String[]
- Specifies an array of file paths containing JavaScript code to be included.
- Link String[]
- Specifies an array of URLs to external JavaScript files to be included.
- Placement String
- Specifies where the JavaScript content should be placed in the HTML document. Valid values are 'Inline', 'Header', or 'Footer'. Default is 'Header'.
- Possible values:
Inline,Header,Footer - ReplaceData IDictionary
- Specifies a dictionary of key-value pairs to replace in the JavaScript code.
- Resource IDictionary
- Specifies the resource containing the JavaScript content.
- ResourceComment String
- Specifies a comment to be included with the JavaScript content.
- SkipTags SwitchParameter
- Indicates whether to skip adding script tags around the JavaScript content. By default, script tags are added.