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 7625377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:04+00:00 2026-05-31T05:11:04+00:00

Here is an interesting jsfiddle. In Firefox: Run the fiddle Click in text input

  • 0

Here is an interesting jsfiddle.

In Firefox:

  1. Run the fiddle
  2. Click in text input
  3. Click somewhere else. Should say “1 blurs”.
  4. Click in the text input again.
  5. ALT–TAB to another window. Fiddle should now say “2 blurs”.

In Chrome, at step 5, it says “3 blurs”. Two separate “blur” events are fired when the whole browser loses focus. This is of interest because it means that it’s not safe to assume, in a “blur” handler, that the element actually had focus just before the event was dispatched; that is, that the loss of focus — the transition from “being in focus” to “not being in focus” — is the reason for the event. When two “blur” events are generated, that condition is not satisfied during the handling of the second event, as the element is already not in focus.

So is this just a bug? Is there a way to tell that a “blur” event is bogus?

  • 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-31T05:11:05+00:00Added an answer on May 31, 2026 at 5:11 am

    The reason it is firing twice is because of window.onblur. The window blurring triggers a blur event on all elements in that window as part of the way javascript’s capturing/bubbling process. All you need to do is test the event target for being the window.

    var blurCount = 0;
    var isTargetWindow = false;
    $(window).blur(function(e){
        console.log(e.target);
        isTargetWindow = true;
    });
    $(window).focus(function(){
        isTargetWindow = false;
    });
    $('input').blur(function(e) {
        if(!isTargetWindow){         
           $('div').text(++blurCount + ' blurs');
        }
        console.log(e.target);
    });
    

    ​
    http://jsfiddle.net/pDYsM/4/

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

Sidebar

Related Questions

I have a string like this: Heading Some interesting text here HeadingSome interesting text
Here's an interesting question. I have a system that attempts to run some initialization
Here's an interesting question ... is there a collection that is a struct somewhere
I've run into an interesting problem here in using heroku + git + SVN.
Here's an interesting writeup of using eye tracking software to generate heat maps that
Here's an interesting problem to solve in minimal amounts of code. I expect the
Interesting one here. I have an ASP.NET 1.1 project that contains a web service
I have an interesting problem here I've been trying to solve for the last
Here's (i think) an interesting question. With AJAX more and more common i feel
Here is the sample code, which produces interesting output: > gg<-data.frame(x=c(a,b),y=as.integer(c(1000,100000))) > gg x

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.