如何检测窗口哈希的变化? [英] How to detect change of window hash?

查看:118
本文介绍了如何检测窗口哈希的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么能检测到 window.location.hash onchange,例如我可以这样做:

How can you detect a window.location.hash onchange, for example I could do this:



<如果我改变散列,例如编辑并在编辑后按Enter键来改变散列值什么也没有发生,只有在窗口重载时才会检测到散列值的变化。

if(window.location.hash.hasChanged()) { // ajax stuff } else { // nothing, no hash has been changed (without any window reload) }

推荐答案

Ben Alman的 hashchange jQuery插件提供了监控更改的散列。

Ben Alman's hashchange jQuery plugin provides the ability to monitor the hash for changes.

这篇关于如何检测窗口哈希的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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