var js = document.scripts;
js = js[js.length - 1].src.substring(0, js[js.length - 1].src.lastIndexOf("/") + 1);

  

如路径为 http://localhost:24395/ABC/XX/a.js

结果会得到    http://localhost:24395/ABC/XX/