/ Published in: JavaScript
Import the other script file. like the java or C++ .
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
****************************************************** // useage: $import('../include/mian.js', 'js'); default is common.js // $import('../style/style.css', 'css'); //****************************************************** function $import(path, type){ var i, base, src = "common.js", scripts = document.getElementsByTagName("script"); for (i = 0; i < scripts.length; i++) { if (scripts[i].src.match(src)) { base = scripts[i].src.replace(src, ""); break; } } if (type == "css") { document.write("<" + "link href=\"" + base + path + "\" rel=\"stylesheet\" type=\"text/css\"></" + "link>"); } else { document.write("<" + "script src=\"" + base + path + "\"></" + "script>"); } }