Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法找出调用 include.js 的 .html 文件的 URL?
我需要找出调用 .js 的 .html 文件的位置,
那可能吗?
会document.location满足你的需要吗?
document.location
您可以使用该window.location.href属性将返回引用 javascript 的服务器端脚本的位置:
window.location.href
alert(window.location.href);
http://foo.com/example.html如果那是引用您的 javascript 文件的页面,则可能会返回。
http://foo.com/example.html