之前搞模組載入,苦於無法獲取當前檔案路徑,檔名:
後來沒通過獲取當前檔案路徑,檔名,給搞定了。
結果今天把這個問題也解決了,做個記錄:
//file: /zhus/err.js:
varcursrc;
newfunction
()
catch
(e)
};//
console.log(cursrc);=>/zhus/err
以上編碼,只適用於firefox,這是我後來測試才發現的,哈哈。so修正如下:
functiongetsrc(node)
return node.lastchild &&arguments.callee(node.lastchild);
}
恩,這樣就好了,但是侷限是,只能是同步載入的方式,如果非同步載入外部js檔案的話,就失效了。。。
獲取當前檔案路徑
getcurrentdirectory只是返回當前程序的當前目錄,而並不是程序的映象檔案 exe 所在的目錄 getcurrentdirectory 適用於xp等系統,在wince上不能使用 getmodulefilename 適用於wince2.0以後 使用方法 下面的一段 主要是獲得當前程式的執...
獲取當前檔案的路徑
一 獲取當前檔案的路徑 1.system.diagnostics.process.getcurrentprocess mainmodule.filename 獲取模組的完整路徑,包括檔名。2.system.environment.currentdirectory 獲取和設定當前目錄 該程序從中啟動的...
獲取當前檔案路徑 當前工作目錄路徑
import os current dir os.path.abspath os.path.dirname file 當前檔案下的絕對路徑 print current dir 輸出 e weidian lc requestinfo current dir1 os.path.dirname file ...