我一直在从事一个编码项目,我一直在尝试在一个 html 文件中拥有多个“页面”(例如 awsomesauce.com/page.html#videos 并仅显示视频部分),同时具有相同的导航栏等到目前为止,javascript 让我失望了。有什么想法吗?
<script>
// Get the current URL (awsomesauce.com/page#videos in this instance)
let url = window.location.href;
// Get the length of the current URL
let urlLength = window.location.href.length;
// Extract the portion of the URL starting from index 21
let = url.substr(21, urlLength);
</script>