0

我的 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(); 在我的更新面板中更新后运行的代码。

谢谢。

4

2 回答 2

0

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

于 2013-07-23T13:21:06.570 回答
0

我有同样的问题。通过将 script type="application/javascript" 更改为 type="text/javascript" 解决了我的问题

于 2013-08-22T18:09:48.647 回答