I have an HTML loading multiple scripts:
<html>
<head>
<script src="scriptDeclaringAGlobalVar.js"></script>
<script src="scriptReadingAGlobalVar.js"></script>
...
scriptDeclaringAGlobalVar.js:
scriptReadingAGlobalVar.js:
$(document).ready(function(){
console.log(aGlobalVar);
});
Though the global variable is declared in the first script, and even $(document).ready was used, it can't be reached, I get errors like this in HtmlUnit:
jQuery.Deferred exception: "aGlobalVar" is not defined. @http://localhost:8080/scriptReadingAGlolbalVar.js:2
@https://code.jquery.com/jquery-3.7.0.js:3479
@https://code.jquery.com/jquery-3.7.0.js:3547
The same works fine in browsers.
I have an HTML loading multiple scripts:
scriptDeclaringAGlobalVar.js:
scriptReadingAGlobalVar.js:
Though the global variable is declared in the first script, and even
$(document).readywas used, it can't be reached, I get errors like this in HtmlUnit:The same works fine in browsers.