'Embedded script does not recognize the variable defined in external script
HTML code:
<!DOCTYPE html>
<html>
<head>
<title>VAST Client JS Test</title>
<meta charset="UTF-8" />
<script
type="text/javascript"
src="src/vast-client-browser.min.js"
></script>
</head>
<body>
<div id="app"></div>
<script type="text/javascript">
// display a text on the page.
document.getElementById("app").innerHTML = "Step 1";
var vastClient = new VAST.VASTClient();
// display a text on the page.
document.getElementById("app").innerHTML = "Step 2";
</script>
</body>
</html>
I put the js file into the src folder.
However, it doesnt work as expected.
As you see above, on my HTML file, I print "Step 1" and "Step 2" text. However, it does not show the text "Step 2" since It was used after using the variable in my JS file.
Also, I get a warning message like "'VAST' is assigned a value but never used."
Please check out my codesandbox demo.
What could I be missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

