I'm trying to create a web part within SharePoint framework which includes <script>
tags however they do not run while in SharePoint, see example code below:
public render(): void {
this.domElement.innerHTML = `
<h1>The script element</h1>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
`;
}
I know that for this example I can just us use the below to get around it.
document.getElementById("demo").innerHTML = "Hello JavaScript!";
But I have some more complicated script (calling an external JS library) which I want to use, see below:
<script id="Microsoft_Omnichannel_LCWidget" src="https://oc-cdn-ocprod.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js" data-app-id="--My data app id--" data-lcw-version="prod" data-org-id="--My org id--" data-org-url="--My org url--"></script>
Which I don't know how to quite as easily convert into typescript for it to work. Any insight into either converting the code into typescript, or getting script tags to work is appreciated, thanks in advance.