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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:19:44+00:00 2026-06-05T08:19:44+00:00

I am trying to identify if the window loses focus after 3 seconds of

  • 0

I am trying to identify if the window loses focus after 3 seconds of submit.

Currently I have this:

$("input").on("submit",function(){
$(window).blur(function(){
  console.log(a);
})
});

But this, no matter when you press submit, if you click outside the window or minimize the window the console.log triggers a.

This is what I am trying to achieve:

  1. User submits form
  2. In a period of 3 seconds, if the window loses focus do console.log(a);
  3. After 3 seconds, if the window loses focus do nothing.
  4. If the user submits again on the same session, repeat from step 1.
  • 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-06-05T08:19:45+00:00Added an answer on June 5, 2026 at 8:19 am

    Try this:

    $("#form").on("submit",function(){
        var blurFunc = function() {
            console.log(a);
        }
    
        $(window).blur(blurFunc);
        setTimeout(function() { $(window).unbind('blur', blurFunc); }, 3000);
    });
    

    The setTimeout call will unbind from the blur event after 3 seconds, causing the event to not fire.

    For more info on setTimeout see here: http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

    Alternatively, you could do something like this:

    $("#form").on("submit",function(){
        var submitted = true;
    
        var blurFunc = function() {
            if(submitted) {
                console.log(a);
            } 
        }
    
        $(window).blur(blurFunc);
        setTimeout(function() { submitted = false; }, 3000);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to identify if this is an IIS issue or a code issue.
Anyone have an idea of why this is popping up? Trying to use this
I am trying to identify file types for directory entries (Windows Unix etc..). In
I'm trying to use Integrated Windows Authentication combined with a DirectorySearcher to identify and
I am trying to identify when an action without authorization has been made. Is
I am trying to identify a screen in a multi-monitor setup to save some
I am trying to identify duplicate serial numbers from the following xml using XPath
I am trying to identify all the nodes in a tree that lead to
I am trying to identify SQL INSERTS that occur when a record is viewed
I'm trying to identify when a particular process is running, based on its arguments,

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.