在Chrome中的页面刷新(F5)后,jQuery表现得很奇怪 [英] jQuery behaving strange after page refresh (F5) in Chrome

查看:116
本文介绍了在Chrome中的页面刷新(F5)后,jQuery表现得很奇怪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,在FireFox,IE中可以正常工作,但是在F5刷新后不能在Chrome中使用!它确实工作在铬,如果我专注的url地址,并点击进入,但它不工作,如果我按F5,我不明白它,这如何可以影响jQuery代码。



所以这里是脚本:

  $(document).ready(function(){ 
var width = 0;
$('#gallery img')。each(function(){
width + = $(this).outerWidth(true);
} );

$('#offer #gallery')。css('width',width +'px');
});

宽度的结果应该是820,但如果我通过重点刷新网站,我只会得到这个结果url地址并点击进入,否则会给出90的结果。

我尝试重新启动浏览器并删除缓存,所以问题不存在,有什么想法? / p>

解决方案

为了解决这个问题,请使用:

  $(window).load(function(){}); 

取而代之:

  $(document).ready(function(){}); 


I have a script, that works fine in FireFox, IE, but not in Chrome after F5 refresh only! It does work in chrome, if I focus the url address and click enter, but it doesnt work if I press F5, I don't get it at all, how can this have an effect on the jQuery code.

So here's the script:

$(document).ready(function() {
    var width = 0;
    $('#gallery img').each(function() {
    width += $(this).outerWidth(true);
    });

    $('#offer #gallery').css('width', width + 'px');
});

And the result of Width should be 820, but I only get this if I refresh the site by focusing the url address and clicking enter, otherwise it gives the result of 90.

I tryed restarting browser and deleting cache, so the problem isn't there, any ideas?

解决方案

To correct this problem use:

$(window).load(function() {});

Out instead of:

$(document).ready(function() {});

这篇关于在Chrome中的页面刷新(F5)后,jQuery表现得很奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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