showing results for - "javascript get current directory"
Melina
24 Feb 2019
1var loc = window.location.pathname;
2var dir = loc.substring(0, loc.lastIndexOf('/'));
3
Valeria
14 Apr 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
queries leading to this page
get current directory javascriptjavascript get script folderjs get current directory namejavascript get current directoryjs print current directoryget current directory in javascriptget current directory path using jsjavascript current directoryhow tpo get directory using jscurrent directory in jsjavascript get the current directoryjavascript get current pathjavascript print current directory contentjs script from pathjavascript get full working directoryjavascript print directoryjavascript get folders in directoryjavascript get current folder nameprint directory content javascriptjs get current dircurrent directory in javascriptjavascript get directoryjs path current directoryfind current directory in javascriptjavascript current folderhow to get current directory of a javascript filejs current folderjavascript get current directory pathget current directory path jsjavascript print current directoryjs get folderjavascript how to print dirhow to get current directory jsget the script directory from src javascriptjavascript print working directoryhow to get currebnt dir in jsjs get current directoryhow to get the directory of a js filecurrent directory javascriptjs get current folder namejavascript how to print working directoryjavascript get current folderget current directory jsget folder jsjs to get a folderpath js scriptjavascript get path of current scriptjs get current folder pathjavascript read current directoryjavascript current dirprint folder javascriptget current working directory javascriptjs get folder of current scriptcurrent directory jsprint current dir javascriptcurrent folder javascriptjavascript get folderjavascirpt get own pathjavascript get current directory