简体   繁体   English

锚链接的id的哈希值将替换为URL中的斜杠

[英]The hash of id of an anchor link is to be replaced with a slash in URL

I am having a static website built in HTML5, and having the scrolling pages. 我有一个HTML5内置的静态网站,并有滚动页面。 The link to the pages is specified by the help of inline anchor tag, and with the help of an Id it scrolls to the particular div and the url changes. 页面的链接由内联锚标记的帮助指定,并且在Id的帮助下,它滚动到特定的div并且URL发生变化。 for eg mysite.com#section1 if I move to secion 1 div. 例如mysite.com#section1如果我移动到secion 1 div。

I want to replace this # to / in the url and the page should be scrolling as well. 我想将这个#替换为url中的/ ,页面也应该滚动。

Can anyone please help me in achieving this. 任何人都可以帮助我实现这一目标。

Thanks in advance :) 提前致谢 :)

你可以使用jquery或js

 url = url.replace("#", "/");

Its great that you are using HTML5. 您使用HTML5非常棒。
The goodies which this great 5th version of HTML has bestowed upon us include the History API 这个伟大的第5版HTML提供给我们的好东西包括History API
With this API you can change the page URL (within the same domain) without redirecting/reloading. 使用此API,您可以更改页面URL(在同一个域中),而无需重定向/重新加载。
The function is pushState . 该函数是pushState

-Relfor -Relfor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM