跳转到锚定标记而不在URL中显示井号 [英] Jump to anchor tag without showing hashtag in URL

查看:119
本文介绍了跳转到锚定标记而不在URL中显示井号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击帖子标题时,我当前正在使用jQuery在特定主题标签上加载页面(通过body类中的onload函数).标签显然显示在url中.我想知道是否存在一种隐藏主题标签的方法,以免使URL混乱.进行了一些搜索,但没有提出太多建议.

I am currently using jQuery to load a page at a specific hashtag (via onload function in the body class) when a user clicks on a post title. The hashtag obviously shows up in the url. I was wondering if there was a way to hide the hashtag from cluttering up the URL. Did some searches and did not come up with much.

function goToAnchor() {
    location.href = "#post";
}

推荐答案

如此处所示:

只需传递要滚动到的元素的ID.

Just pass the id of the element you wish to scroll to.

这篇关于跳转到锚定标记而不在URL中显示井号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆