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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:34:39+00:00 2026-05-16T10:34:39+00:00

Here is what I am thinking: When a user browses some other page, or

  • 0

Here is what I am thinking:

When a user browses some other page, or uses different application, or to say straight is not actively interacting with the webpage I want to catch this as a event and trigger a fadeIn() function. In this particular case only, I want to fill the page with shadow, which fades out once the user is back.

The question is , How to catch this event, and execute a function?

Created a demo here but I want the shadow to fade in, when the mouseout event triggers in window, but if I do so, when I come back in the body, the window start pulsating.

  • 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-16T10:34:40+00:00Added an answer on May 16, 2026 at 10:34 am

    It’s really easy. Just use the blur and focus events on window. You can do whatever you want to show/hide your page shadow in the callbacks. Personally, I’d recommend the BlockUI plugin.

    $(function()
    {
        var $body = $('body');
        $(window).focus(function () { $body.removeClass('fade'); })
                 .blur(function () { $body.addClass('fade'); });
    });?
    

    Working example: http://jsbin.com/idipo5/2 (tested in Chrome) (be forewarned, it’s really ugly)


    Edit: I’m pretty this what you’re going for. Note how it doesn’t unmask if the window is moused-over but doesn’t have focus. If you do want it to unmask in this case, you can remove the focused flag and its checks.

    Tested in Chrome and FF (IE is a miserable piece of not-worth-my-time):

    http://jsbin.com/ufido3

    Posting the JS code below, since I’m not sure how long JSBin keeps your stuff around.


    $(function ()
    {
      var $modal = $('#modal'),
          masked = false,
          focused = true;
    
      function mask()
      {
        if (!masked)
        {
          $modal.fadeIn('fast');
          masked = true;
        }
      }
    
      function unmask()
      {
        if (masked && focused)
        {
          $modal.fadeOut('fast');
          masked = false;
        }
      }
    
      $('html').hover(unmask, mask).focus(function (e)
      {
        e.stopPropagation();
        if ($(e.target).is('html')) unmask();
      }).blur(function (e)
      {
        e.stopPropagation();
        if ($(e.target).is('html')) mask();
      });
    
      $(window).focus(function ()
      {
        focused = true;
        unmask();
      }).blur(function ()
      {
        focused = false;
        mask();
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading some questions here on SO about conversion operators and constructors got me thinking
I could not sleep last night and started thinking about std::swap . Here is
Some of the guys here are developing an application which incorporates some 'secure areas'
i dont know if i should be asking this here (im now thinking maybe
Here's something I've been thinking about: suppose you have a number, x, that can
I have been thinking quite a bit here lately about screen scraping and what
Thinking that the answer to this is pretty obvious but here it goes: When
Maybe I'm thinking about this the wrong way but here's the idea: Class A
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Started using thinking sphinx today and I'd like to know what's going wrong here:

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.