4

I have a script tag with an src, how can I reload the src with java script code, this is the code I have:

<script src='./script.php'>
<script>
function reload() {
  //the code to reload the src
}
</script>
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

1 Answers1

1

Snippet:

<script>
        function reload() {
          var head= document.getElementsByTagName('head')[0];
          var script= document.createElement('script');
          script.src= './script.php';
          head.appendChild(script);
       }
       reload();
</script>
Barr J
  • 10,636
  • 1
  • 28
  • 46