使用此代码,我将获得执行脚本的完整路径,在这种情况下services.js
:
JS
var scripts = document.getElementsByTagName("script"),
src = scripts[scripts.length-1].src;
alert(src);
输出示例:
file:///C:/Users/fel/Desktop/currencies-gh-pages/js/services.js
但我想要这样的输出:
file:///C:/Users/fel/Desktop/currencies-gh-pages/js/
任何的想法?