使用js调用js

直接上源码:

 <div class="choose">
     choose a mode<br>
     <hr>
         <button type="submit" id="easy" onclick="easymode()"> Easy </button>
         <button type="submit" id="hard" onclick="hardmode()"> Hard </button>
         <button type="submit" id="crazy" onclick="crazymode()"> Crazy </button>
         <br><hr>
         
     </div>
     <script>
         /*easy*/
        function easymode()
        { var script=document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("language","javascript");
script.setAttribute("src","baselevel.js");
document.getElementsByTagName("body")[0].appendChild(script);}
        /*hard*/
         function hardmode()
        { var script=document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("language","javascript");
script.setAttribute("src","hardlevel.js");
document.getElementsByTagName("body")[0].appendChild(script);}
         /*crazy*/
         function crazymode()
        { var script=document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("language","javascript");
script.setAttribute("src","crazylevel.js");
document.getElementsByTagName("body")[0].appendChild(script);}
</script>

 

posted @ 2018-04-16 21:18  宸少凌  阅读(953)  评论(0编辑  收藏  举报

万年以来谁著史,三千里外欲封侯