I'm trying to get js code from somewhere else and run it But it did not run after loading
Does anyone know how to run? (Code here)
thanks
<html>
<head>
</head>
<body>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = 'http://localhost/check.js';
document.getElementsByTagName('head')[0].appendChild(script);
}
</script>
</body>
</html>
js page:
alert("work?");