php动态创建js

js.php

<?php
 echo '
 <script type="text/javascript">
   function addScript(){
   var script = document.createElement("script");
   script.setAttribute("type","text/javascript");
   script.setAttribute("src","123.js");
   var hd = document.getElementsByTagName("head")[0];
   hd.appendChild(script);
   }  
  </script>';
?>

123.js

alert("addddddddddd");

 

你可能感兴趣的:(php动态创建js)