//页面加载时不存在,加载完时再添加 function loadScript(url) {//外部文件var script = document.createElement("script");script.type = "text/javascript";script.src = url;document.body.appendChild(script); }function loadScriptString(code) {//行内样式var script = document.createElement("script");script.type = "text/javascript";try {script.appendChild(document.createTextNode(code));} catch (ex) {script.text = code;}document.body.appendChild(script); }