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 ファイルの場所を見つける必要があります。
それは可能ですか?
window.location.hrefjavascript を参照したサーバー側スクリプトの場所を返すプロパティを使用できます。
window.location.href
alert(window.location.href);
http://foo.com/example.htmlそれがあなたのjavascriptファイルを参照したページであった場合、返される可能性があります。
http://foo.com/example.html
document.locationあなたのニーズに合うでしょうか?
document.location