[英]Display the current page's hash/anchor in the page's body with JavaScript
使用window.location.hash
獲取錨點的名稱。
var anchorName = window.location.hash;
創建一個文本節點以顯示所需內容:
var path = document.createTextNode("→ " + anchorName);
將其添加到Dom中:
document.getElementById(idOfContainerYouWantToEdit).appendChild(path);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.