开发者

jquery working in all browsers except Opera

I have the following jquery code which seems to be working fine in all browsers except Opera on window.load; but on window.resize, it works okay.

function resizeMargin() {

    var h = $(window).height(),
        w = $(window).width(),
        wrapMargin = (h - 655) / 2,
        bgImage = wrapMargin + 105,
        pageWidth = ((w - 690) / 2) + 340;


    $('#navigation').css({'padding-top' : wrapMargin + 'px', 'display' : 'block'});
    $('#logo').css({'top' : bgImage + 'px', 'display' : 'block'});
    $('.page-content').css({'margin-top' : bgImage + 'px'});

    if (h < 670) {
        $('#navigation').css({'padding-top' : 50 + 'px', 'display' : 'block'});
        $('#logo').css({'top' : 120 + 'px',  'display' : 开发者_运维问答'block'});
        $('.page-content').css({'margin-top' : 130 + 'px'});
    }

    $('#page-right').css({'width' : pageWidth + 'px', 'display' : 'block'});
    $('#page-left').css({'display' : 'block'});

    var shiftWidth = $(window).width();
    $('#content').animate({left : shiftWidth}, 0).delay(800).css({'display' : 'block'});

}

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

$(window).resize(function () {
    resizeMargin();
});

I'd really appreciate it if someone could point out where I'm going wrong. I'm pretty stumped! (and I'm not brilliant at jquery, so that doesn't help!)


As per jimy's comment, I used $(document).ready, rather than $(window).load and all is working fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜