Javascript: How Can I Know Where Is The .js Self?
I write a small javascript library, it use a image. I want to build the directory structure like this:  /lib    /mylib       main.js       /img           main.png    /other librari
Solution 1:
You can extract it from your <script> tag:
function getScriptPath() {
  var scriptTags = document.getElementsByTagName('script');
  return scriptTags[scriptTags.length - 1].src.split('?')[0].split('/').slice(0, -1).join('/') + '/';
}
Post a Comment for "Javascript: How Can I Know Where Is The .js Self?"