1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html>
  5. <head>
  6. <title>Dynamically Loading JavaScript :: Loading thru Src</title>
  7. <script type="text/javascript">
  8.  
  9. function dynamicLoadJS(scriptName) {
  10. var head = document.getElementsByTagName("head")[0];
  11. script = document.createElement('script');
  12. script.id = "DynaScript";
  13. script.type = 'text/javascript';
  14. script.src = scriptName;
  15. head.appendChild(script);
  16.  
  17. document.getElementById("LoadJS").disabled="true";
  18. document.getElementById("CallJS").disabled="";
  19. }
  20. </script>
  21. </head>
  22. <body>
  23. <button id="LoadJS" onclick="dynamicLoadJS('./onDemandJs.js');">Load JavaScript</button>
  24. <button id="CallJS" onclick="showHtml();" disabled="disabled">Call method from new load</button>
  25. </body>
  26. </html>
  27.  
  28.