I have this file: a.js
export function work(){
// do stuff
}
And this jsp file:
...
<script type="text/javascript" src='<c:url value="/javascripts/a.js"/>'></script>
...
How do I call the function "work" from my jsp file? It always says "work is not defined"
Attempted (deeper in the jsp):
...
<th><a href="#" onclick="return work();" > Work # </a></th>
...
"return window.work();"? Since the script is in the HEAD, the DOM may not be initialized yet. You may need to listen forDOMContentLoaded.href="#"— if you're linking to the top of the page then you probably shouldn't be using a link and should be using a<button>instead.