JQUERY + location.reload()回调 [英] JQUERY + location.reload() callback

查看:352
本文介绍了JQUERY + location.reload()回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户更改语言时,我正在使用带有JQUERY的location.reload()进行刷新. 我想问问location.reload()之后是否可能有回调?

I'm using a location.reload() with JQUERY to refresh when a user changes language. I wanted to ask if its possible to have a callback after location.reload()?

我以为不是刷新页面,但是有可能.

I kind of assume not as it refreshes the page but it might be possible.

请让我知道.

thx

推荐答案

我对此表示怀疑,但是我认为您的问题还有另一种解决方案.饼干.如果要使用Cookie来指示用户已更改语言,则可以在看到该Cookie时执行所需的逻辑.这种方法可能行得通.如果您需要早期截取JavaScript,则可能需要将javascript放在html页面的顶部,并将其放在任何document.load或文档就绪的函数之外,以便快速进行评估.

I doubt that it is, however I believe that there is another solution to your problem. Cookies. If you were to use a cookie to indicate that the user had changed languages you can then perform the logic you want upon seeing that cookie. That approach could work. If you needed to have early javascript interception you might need to have your javascript at the top of your html page and outside of any document.load or document ready functinons so that it evaluates quickly.

在我看来,这似乎是个小问题,因此,尽管我为您的问题提出了解决方案,但我不支持这种方法.

This does seem like hackery to me, so althought I have proposed a work around for your question I dont stand behind the recommending the approach.

这篇关于JQUERY + location.reload()回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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