(function(){
this.__defineGetter__("__FILE__", function() {
return (new Error).stack.split("\n")[2].split("@")[1].split(":").slice(0,-1).join(":");
});
})();
this.__defineGetter__("__FILE__", function() {
return (new Error).stack.split("\n")[2].split("@")[1].split(":").slice(0,-1).join(":");
});
})();
非常聪明的办法 :D
from: http://ejohn.org/blog/__file__-in-javascript/