I am wondering if there is a way to call a Javascript Function that is inside a Module-type script from a normal script.
For example:
HTML:
<body>
<button onclick="myFunction()">Click Here</button>
</body>
Normal Script:
function myFunction() {
alert("Calling Module Function!");
moduleFunction();
}
Module Script:
/// Module stuff that requires this to be a module script
function moduleFunction() {
alert("This was called from inside a module script");
// Info only accessible inside module script
}
I have tried the above code on my site, and I only get an Uncaught Reference error that the function name is not defined. Are there more steps I must take in order to use functions throughout the scripts?
Thanks!
exportsomething you need toimport, whether it's individual methods or an object that provides those methods. How have youimported the the module/library?import { moduleFunction } from ...? I don't know what the from would be because these are all in one HTML file.