链接到本地托管网站中的某个位置
问题描述:
我正在尝试将我的本地托管网站链接到特定 ID(网站内部),如下所示:
I'm trying to have my locally-hosted website link to a specific id (inside the website) as follows:
<button onclick="location.href='http://127.0.0.1:5500/#projects'"
onmouseover="onbutton(this)" onmouseout="offbutton(this)"
type="button">Projects</button>
但是,它不起作用(单击时我浏览器中的 url 更改为 127.0.0.1:5500/#projects,但超链接不会更改我正在查看的页面的哪一部分.我怀疑这是因为ip 不是真正的 url.当我的网站在本地托管时,有什么方法可以创建指向 id projects
的超链接?
However, it is not working (the url in my browser changes to 127.0.0.1:5500/#projects when clicked, but the hyperlink does not change which part of the page I'm looking at. I suspect it's because the ip is not a real url. Is there any way I can create a hyperlink to the id projects
when my website is being locally hosted?