[英]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.