使用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>
笔者:宸少凌