onload JavaScript函数在页面重新加载/导航时表现得很糟糕

时间:2017-04-28 23:54:08

标签: javascript jquery

使用浏览器上的后退按钮访问页面时,以下脚本不会触发。无论页面访问方式如何,都有办法解雇它吗?

window.onload = function() {
    var quotes = $(".head-banner");
    var quoteIndex = -1;
    function showNextQuote() {
        ++quoteIndex;
        quotes.eq(quoteIndex % quotes.length).fadeIn(1500).delay(4500).fadeOut(1500, showNextQuote);
    }
    showNextQuote();
}();
/* Background Transitions */
window.onload = function() {
  var images = ["https://unsplash.it/1800/1600?image=1006", "https://unsplash.it/1800/1600?image=1008"];
  var imageIndex = -1;
    function showNextImage() {
        ++imageIndex;
        var imgUrl = images[imageIndex % images.length];
        $('#header').css('background-image', 'url(' + imgUrl + ')');
        $('#header').fadeIn(1500).delay(4500).fadeOut(1500, showNextImage);
    }
    showNextImage();
}();

编辑:自发布以来我已经了解了旋转木马是什么

0 个答案:

没有答案
相关问题