topical media & game development

talk show tell print

mashup-amazon-12-12-02-DynamicScriptExample-DynamicScriptExample.htm / htm



  <html>
  <head id="myHead">
  <script language="javascript">
  
  function AddScript( ) {
     var myTag = CreateScriptTag();
     document.getElementById("myHead").appendChild(myTag);
  }
  
  function CreateScriptTag(){
     var myScript = document.createElement("script");
     myScript.setAttribute("type", "text/javascript");
     myScript.setAttribute("src", "alert.js" );
     return myScript; 
  }
  
  </script>
  
      <link href="styles.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
      <div class="siteHeading">Dynamic Script Example</div>
      <div class="mainTable">
          This example demonstrates how to dynamically add javascript to a given page. <br/>
          <a href="javascript:void(0)" id="myTrigger" onclick="javascript:AddScript()">Click to Add JavaScript</a>
      </div>
  </body>
  </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.