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.
ユーザーがhttp://somedomain.com/path/file.html#fooというページにアクセスしたとします。JavaScript を使用して、ページのどこかに次のようなテキストを表示したいと思います。
→ foo
window.location.hashアンカーの名前を取得するために使用します。
window.location.hash
var anchorName = window.location.hash;
必要なものを表示するテキスト ノードを作成します。
var path = document.createTextNode("→ " + anchorName);
それを Dom に追加します。
document.getElementById(idOfContainerYouWantToEdit).appendChild(path);