可能重复:
How might I get the script filename from within that script?
JavaScript - How do I get the URL of script being called?
如何在我的javascript代码中确定javascript加载的网址,例如:如果我有一个页面http://www.example.com/index.html
<html>
<script src='/code/whereami.js'></script>
...
然后我的javascipt将从http://www.example.com/code/whereami.js加载,但如何在代码中找到此网址?
(是的,根据定义,作为程序员,我应该知道我的文件在哪里 - 这里的练习点是验证结果页面的完整性)