Return to Snippet

Revision: 9099
at October 21, 2008 05:34 by liuran


Initial Code
******************************************************
// 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>");
  }
}

Initial URL

                                

Initial Description
Import the other script file. like the java or C++ .

Initial Title
import the other file in javascript

Initial Tags

                                

Initial Language
JavaScript