I want to execute javascript from downloaded html file. I use XMLHttpRequest to get the html response.
function load2element() { localStorage.setItem("geadele", "cool variable is passed"); var client = new XMLHttpRequest(); client.open('GET', '/geadele/geadele/gesurvey.html'); client.onreadystatechange = function() { el.innerHTML = client.responseText; // << file with javascript } client.send(); } imported gesurvey.html contains javascript codes for execution:
<script> console.log("From gesurvey.html"); console.log(localStorage.getItem("geadele")); // should "cool variable is passed" </script> <div>I am survey</div>