📜  javascript 获取脚本路径名 - Javascript 代码示例

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

代码示例1
window.getRunningScript = () => {
    return () => {      
        return new Error().stack.match(/([^ \n])*([a-z]*:\/\/\/?)*?[a-z0-9\/\\]*\.js/ig)[0]
    }
}
console.log('%c Currently running script:', 'color: blue', getRunningScript()())