I use the SharePoint Online Modern Experience.
I am trying to run Javascript in my sharepoint online page but it will not run. It runs on my computer however and correctly displays the resultant page.
This is my HTML file called test.html. It is both on my computer and SharePoint online:
<html>
<h1>The script element</h1>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
</html>
As mentioned above it runs and displays correctly on my computer like so:
I created a SharePoint page and used the Embed web part to reference this HTML file using iFrame. My iFrame code is like so:
<iframe id="inlineFrameExample" title="Inline Frame Example" width="300" height="200" src="path to above HTML file">
</iframe>
Unfortunately, the javascript script is not run; "Hello JavaScript!" is not displayed. This is what is displayed on the sharepoint online web page
How do I get the javascript to execute?