showing results for - "js get folder of current script"
Lucia
02 Mar 2018
1var scripts= document.getElementsByTagName('script');
2var path= scripts[scripts.length-1].src.split('?')[0];      // remove any ?query
3var mydir= path.split('/').slice(0, -1).join('/')+'/';  // remove last filename part of path
4
5function doSomething() {
6    img.src= mydir+'../images/myimage.jpeg';
7}
8