📜  javascript 获取当前目录 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:09.429000             🧑  作者: Mango

代码示例2
var scripts= document.getElementsByTagName('script');
var path= scripts[scripts.length-1].src.split('?')[0];      // remove any ?query
var mydir= path.split('/').slice(0, -1).join('/')+'/';  // remove last filename part of path

function doSomething() {
    img.src= mydir+'../images/myimage.jpeg';
}