Javascript - 我的网址是什么?

时间:2012-05-18 16:26:23

标签: javascript url

  

可能重复:
  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加载,但如何在代码中找到此网址

(是的,根据定义,作为程序员,我应该知道我的文件在哪里 - 这里的练习点是验证结果页面的完整性)

0 个答案:

没有答案