简体   繁体   English

页面刷新后jquery停止工作

[英]After page refresh jquery stops working

这真是一个奇怪的问题,我的页面中有很多插件和自定义脚本,而且一切正常,但是如果我想尝试刷新页面,不只是点击一些链接,我的一些脚本就会停止工作,主要是改变css属性的人,我的firebug没有显示任何错误,可能导致类似的东西?

Answer from original poster: 来自原始海报的回答:

So the problem was that i used $(document).ready() what i realy needed was $(window).load() 所以问题是我用$(document).ready()我真正需要的是$(window).load()

I know this is an old question I stumbled upon. 我知道这是一个我偶然发现的老问题。 Anyway, my answer might help another when the same problem arises. 无论如何,当出现同样的问题时,我的答案可能会帮助另一个人。 Unfortunately I haven't got the reputation to comment on Trott's answer above. 不幸的是,我没有对Trott的回答发表评论。

That being said, if you are using jQuery 1.8 or any version after his, then use $(window).on('load', function() { ... }); 话虽这么说,如果你使用的是jQuery 1.8或者他之后的任何版本,那么使用$(window).on('load', function() { ... }); . The $(window).load() was deprecated in jQuery version 1.8 and will throw the error jquery url.indexOf is not a function (at least in jQuery 3.4.1) $(window).load()在jQuery版本1.8中已弃用,并将抛出错误jquery url.indexOf is not a function (至少在jQuery 3.4.1中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM