在哈希标签后获取网址值 [英] Get url value after hash tag

查看:84
本文介绍了在哈希标签后获取网址值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果访问了下面的URL,并且找到了标签"about"(请参阅​​下面的链接)之后的值,我希望触发一个特定的函数.请问我该如何实现?

http://www.site.com/index.html#about.html

这种方法是我认为,当使用后退和前进浏览器按钮而不是主菜单时,可以控制网页中的动画标题,否则该主菜单将控制其动画状态.我希望这一切都说得通.

If the url below is visited and the value after the hashtag ''about'' (Refer to link below) is found, I would like a specific function to be triggered. How would I achieve this please?

http://www.site.com/index.html#about.html

This method is a way I figured I could control an animated header in my webpage when the back and forward browser buttons are used instead of the main menu which would otherwise control its animation states. I hope this all makes sense.

推荐答案

jQuery hashchange事件是一种方法.或者,您可以简单地使用 window.location.hash .
jQuery hashchange event would be one way. Or you could simply use window.location.hash.


这篇关于在哈希标签后获取网址值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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