$(窗口).hashchange()不工作 [英] $(window).hashchange() doesn't work

查看:131
本文介绍了$(窗口).hashchange()不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我试图用浏览器后退按钮,我知道如何捕捉与hashchange插件事件=>

I'm trying to use the browser back button, i understood how to catch the event with hashchange plugin =>

$(window).hashchange( function(){
    alert( location.hash );
});$(window).hashchange();

当我尝试加载新的页面,没有任何反应.. 有没有一种方法,以刷新页面用新的网址是什么?

When i try to load the new page, nothing happens.. Is there a way to "reload" the page with the new url ?

谢谢!

推荐答案

试试这个来代替:

$(window).on('hashchange', function(){
    // Your code goes here
}).trigger('hashchange'); // bind event to the same selector as event-listener

.trigger() basicly激活事件手动。

.trigger() basicly activates events manually.

编辑:
这应该足以为您的工作。


This should be enough for you to work.

尝试这块code 的,看看你有没有运气。

Try this piece of code and see if you got any luck.

包括javascript.js为com pressed与jQuery和hashchange。

Included javascript.js is compressed with jquery and hashchange.

这篇关于$(窗口).hashchange()不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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