0
是否可以在运行时确定它? external.js的确定在外部js文件中调用函数的HTML页面
内容:test.html的
脚本SRC = “external.js” 的
function x() {
//can i get the path/name of the html file that included this js file?
//which is test.html
}
内容
+1,我希望我没有浪费时间格式化他的代码现在哈哈;-) – 2010-05-28 19:03:03
+1 ..简单的答案。 @UICodes:当你的JS代码被执行时,它会作为包含它的任何文件的一部分运行。因此获取当前文档地址会给你包含它的文件。 – Senthil 2010-05-28 19:03:36
哈哈,对不起安迪的头!对不起,Senthil,我的答案不那么简单,因为标题中的问题与正文中的问题略有不同...... – bobince 2010-05-28 19:07:01