Add script content to page on runtime - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Script


Add script content to page on runtime

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w  w .  ja  va  2 s .  co m*/
var script = document.createElement('script');
script.text = "var a = 1;console.log(a);" ;
//to use external js then use src


Related Tutorials