I have this HTML:
<!DOCTYPE html>
<html>
<head>
{% load static %}
<script type="text/javascript" src="{% static 'js/bundle.js' %}">
<meta charset="utf-8" />
<title>title</title>
</head>
<body>
<p id="url"></p>
</body>
</html>
And the script file:
(async () => {
....
function makeOutput() {
return 'a url'
}
url = makeOutput()
window.onload = function() {
document.getElementById("url").innerHTML=url;
}
....
})()
I want to use the url variable in the HTML, but for some reason it isn't letting me save variables the same as as if I were using a script tag with all the code in it.
Any ideas on how to go about this? Thanks