IE 8中的jQuery .width()问题 [英] jQuery .width() issues in IE 8

查看:118
本文介绍了IE 8中的jQuery .width()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用width(), outerWidth(), innerWidth()

如果您在IE8中加载此URL ,那么我得到的宽度图将超过30,000,而其他所有浏览器在1100标记附近,这是正确的值.

If you load up this URL in IE8 it gives me a width figure of over 30,000 whereas every other browser is around the 1100 mark which is the correct value.

这会导致滑块出现问题,因为此宽度值用于针对各个滑块的大小进行各种其他计算.

This causes problems with the slider as this width value is used to make all sorts of other calculations in regards to the individual slider resizings.

我已将警报留给您查看宽度差异,并且它在具有id容器的div上被调用.

I have left the alert in for you to see the width discrepencacies and it is being called on the div with id container.

特定的jQuery调用是(不因其他插件而引起冲突):

The specific jQuery call is (using no conflict due to other plugins):

alert(jQuery_1_6_2('#container').width());

我看过其他一些文章,提到了outerWidth()innerWidth(),但是这些也不能给我正确的尺码.

I've seen a few other posts mentioning outerWidth() and innerWidth() but these don't give me the correct sizings either.

我认为可能与IE有关,可能是因为所有滑块都在一条直线上,但每个滑块的宽度仅为600px,所以我只能得到3,600px左右的值,而不是30,000px +

I believe it may be to do with IE maybe thinking that all the sliders are in a line but still these are only 600px wide each so I would only get a value around 3,600px not 30,000px +

我也不能使用固定宽度来解决我的问题,因为它具有响应能力.我能达到的最佳效果是将最大宽度值放在#container上,但是我仍然没有获得确切的宽度值.

I also can't use fixed widths which would solve my problem due to this being responsive. The best I can achieve is put a max-width value on #container but I still don't get an exact value for the width value.

推荐答案

尝试使用$(window).load(function(){...});代替准备好的文档.

Try to use $(window).load(function(){...}); instead of document ready.

如果仍然无法正常工作,则可以使用计时器使DOM完全呈现:

If still not working, then this could work, using a timer let the DOM be fully rendered:

jQuery_1_6_2(document).ready(function () {
    setTimeout(function () {
        alert(jQuery_1_6_2('#container').width());

        jQuery_1_6_2('#accordion-wrapper').raccordion({
            speed: 1000,
            sliderWidth: jQuery_1_6_2('#container').width(),
            sliderHeight: 360,
            autoCollapse: false
        });
    }, 100);
});

这篇关于IE 8中的jQuery .width()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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