Relative path to the JavaScript file. When calling loadScript
, <portal>/external/htmlroot/
is the current directory.
A promise that resolves when the script has been loaded.
Only scripts within a <portal>/external/htmlroot/<folder>
directory can be loaded. More specifically, the script must be located in one of the following folders: css
, fonts
, images
, include
, script
or thirdparty
.
// Load `myScript.js` which is stored in the `<portal>/external/htmlroot/script` directory.
// For example, functions stored in `myScript.js` can now be called from the Web Browser's console.
ix.api.dom.loadScript('script/myScript.js')
.then((ok) => {
if (ok) {
// Script has been loaded successfully
// Add your code here to use the loaded script
console.log('Script has been loaded successfully');
}
})
.catch((error) => {
// Error occurred while loading the script
console.error(error);
});
Load a JavaScript file on demand. Its content, like functions or variables, are then available in the Web Browser.