$ document准备好不在ie8中工作

时间:2012-04-27 13:44:45

标签: jquery internet-explorer-8

我的javascript无法在IE8中运行时出现轻微问题。在firefox,ie9和chrome中工作正常,但不是ie8。我知道它与ie8中的文档准备工作有所不同,但我找不到答案。请参阅下面的代码。

// JavaScript Document
/* Set Opacity to 0 for all list items that do not have class show
This prevents the gallery animation from jumping around unexpectedly.
*/
function clearShowClass() {
    setTimeout(timedInterval, 1000);
};

function timedInterval() {
    $('ul.slideshow li').not('.show').css("opacity", 0);
    clearShowClass();
};


function slideShow(speed) {

    //Call the gallery function to run the slideshow
    var timer = setInterval('gallery()', speed);

    //Pause the slideshow on mouse over content
    $('#footer, ul.slideshow').hover(

    function () {
            clearInterval(timer);
    },

    function () {
            timer = setInterval('gallery()', speed);
    });
} // End of slideshow
/* Slideshow gallery main images */

function gallery() {
    //if no IMGs have the show class, grab the first image
    var current = ($('ul.slideshow li.show') ? $('ul.slideshow li.show') : $('#ul.slideshow li.first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption') ? $('ul.slideshow li:first') : current.next()) : $('ul.slideshow li:first'));

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({
            opacity: 4.0
    }).addClass('show').animate({
            opacity: 4.0
    }, 1000);

    // Hide the current image
    current.animate({
            opacity: 0.0
    }, 1000).removeClass('show');

    //if no thumbnails have the highlight class, grab the first thumbnail
    var currentThumb = ($('#footer li.highlight') ? $('#footer li.highlight') : $('#footer li:first'));

    var nextThumb = ($('#footer li:last').hasClass('highlight')) ? $('#footer li:nth-child(1)') : $('#footer li.highlight').next($('#footer li'));

    nextThumb.addClass('highlight');
    currentThumb.removeClass('highlight');
}; // End of Gallery
function thumbInt() {
    for (i = 1; i <= $('ul.slideshow li').length; i++) {
            $('#footer .thumbnail' + i).bind('click', {
                    iteration: i
            }, function (event) {
                    $('ul.slideshow li').removeClass('show').css("opacity", 0).add($('ul.slideshow li:nth-child(' + event.data.iteration + ')').addClass('show').css("opacity", 0.0).animate({
                            opacity: 1.0
                    }, 1000));

                    $('#footer li').removeClass('highlight').add($('#footer li:nth-child(' + event.data.iteration + ')').addClass('highlight').add($('#footer li:nth-child(' + event.data.iteration + ') img')));
            });
    };
};

var prmEnd = Sys.WebForms.PageRequestManager.getInstance();
prmEnd.add_endRequest(function () {

    thumbInt(); // Assign int to thumbnail list items
    clearShowClass(); // Prevents multiple li having .show
    $('#footer img').mouseover(

    function () {
            $(this).animate({
                    opacity: 3.7
            })
    });

    $('#footer img').mouseout(

    function () {

            $(this).animate({
                    opacity: 0.7
            })
    });

    //Set the opacity of all images to 0
    $('ul.slideshow li').css({
            opacity: 0.0
    });

    //Get the first image and display it (set it to full opacity)
    $('ul.slideshow li:first').css({
            opacity: 1.0
    }).addClass('show');

    //Get the first thumbnail and change css
    $('#footer li:first').css({
            opacity: 1.0
    }).addClass('highlight');

});



$(document).ready(function () {

    slideShow(6000);

    thumbInt(); // Assign int to thumbnail list items
    clearShowClass(); // Prevents multiple li having .show
    $('#footer img').mouseover(

    function () {

            $(this).animate({

                    opacity: 3.7

            })

    });


    $('#footer img').mouseout(

    function () {

            $(this).animate({
                    opacity: 0.7
            })
    });

});

此页面的工作方式是用户单击单选按钮以触发_dopostback并显示图库。问题是当我执行_dopostback时,文档就绪代码不再有效,但这只发生在ie8中。我正在使用Sys.WebForms.PageRequestManager.getInstance();在我的更新面板中进行更新后运行的代码。

感谢。

2 个答案:

答案 0 :(得分:0)

有同样的问题。 IE8 document.ready功能甚至没有触发警报。 我通过将jquery版本从1.10.1更新到1.10.2并且还包括推荐的迁移js来解决了这个问题。

答案 1 :(得分:0)

我遇到了同样的问题。通过将脚本类型=“application / javascript”更改为type =“text / javascript”

来解决我的问题
相关问题