It is necessary to insert through innerHTML in js into the desired div through id two scripts of the form <script>...</script><script>...</script> . Is there any way to put them into files? If possible, please tell me how? And how to get them through innerHTML? Thank you in advance!

Closed due to the fact that the essence of the question is not clear to the participants of VenZell , Grundy , cheops , zRrr , aleksandr barakin 10 Jun '16 at 12:27 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    In general, nothing is clear what you want and what does not work. If you want to insert via InnerHTML , do insert it through it - Grundy
  • Try to write more detailed questions. Explain exactly what you see the problem, how to reproduce it, what you want to get as a result, etc. - Nicolas Chabanovsky

2 answers 2

You cannot add a script tag through innerHTML , as the standard prohibits the execution of such scripts for security purposes. Use more standard methods that are described on the Internet, for example:

 var script = document.createElement('script'); script.setAttribute('src','http://example.com/site.js'); document.head.appendChild(script); 

    I think it would be more convenient to use jquery. And so, here you can see a couple of useful techniques for this property.