Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7170953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:18:55+00:00 2026-05-28T15:18:55+00:00

I have a piece of code: var logo = $(#blinking-logo); function logo_blink() { logo.fadeOut(10).delay(10)

  • 0

I have a piece of code:

var logo = $("#blinking-logo");
function logo_blink() {
    logo.fadeOut(10).delay(10)
        .fadeIn(10).delay(20)
            .fadeOut(10).delay(10)
            .fadeIn(10)
    window.setTimeout(logo_blink, (Math.random()*(1500))+1500);
}
logo_blink();

All it makes is blinking a picture once in ~30 seconds (time is less here for easier debugging)

The problem that Chrome pauses this timer while the tab in backgrounded, and then, when coming back to that tab, it blinks all the blinks that were missed in background.

I’d like to pause the timer while in background, but I don’t know how. I’ve read some related posts, but it seems that they describe the opposite problem. Is there any way to detect the backgrounding of a tab?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:18:55+00:00Added an answer on May 28, 2026 at 3:18 pm

    It is a known feature. To conserve the resources Chrome does not update the window without focus 🙂 You could check, for example, that window lost its focus and stop the timer. Start it again when window is in focus. For example:

    var timer = null;
    var logo = $("#blinking-logo");
    function logo_blink() {
        if(timer) clearTimeout('timer');
        logo.fadeOut(10).delay(10)
            .fadeIn(10).delay(20)
                .fadeOut(10).delay(10)
                .fadeIn(10)
        timer = window.setTimeout(logo_blink, (Math.random()*(1500))+1500);
    }
    logo_blink();
    $(window).blur(function(){clearTimeout(timer); timer = null;});
    $(window).focus(function(){if (!timer) timer = window.setTimeout(logo_blink, (Math.random()*(1500))+1500);});
    

    Something like this. On one of my pages with animation a had the same problem with setInterval, so I just pause it when the page is in background.

    if (!$.browser.msie)
    {
        $(window).focus(function(){paused = false;});
        $(window).blur(function(){paused = true;});
    }
    

    And than skipped animation based on the value of paused flag.

    ps: Code is updated with optimization discussed below.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: var myObj = function () { this.complex =
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this piece of code: function func1(text) { var pattern = /([\s\S]*?)(\<\?(?:attrib |if
I have the following piece of code: function checkAmount() { var PayField = document.getElementById('paymentamount');
I have a piece of code like this - <script> var x,m,cloneNodex; function addVtier()
I have this piece of code: $(document).on(click, #breadNavMain, function() { for(var i = 0;
Say you have the following piece of code: function someProcess() { var deferred =
I have this piece of code: this.json.each(function(obj, index) { var li = new Element('li');
I have the following piece of code: var blah = function(x, y){ var e
I have this piece of code: function CallAPI(paramString) { var returnVal; var jqxhr =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.