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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:02:50+00:00 2026-06-17T14:02:50+00:00

I made a Desktop Notification it shows a notification every 1 minute. After 10

  • 0

I made a Desktop Notification it shows a notification every 1 minute. After 10 second, closes itself.

I gone for a lunch , then computer goes to sleep. When i was back i wake my computer then lots of notification starts.

How can i handle that problem? I want if computer sleeps it shouldnt show notification. How can i control it?

Background.js

function show() {

   var notification = webkitNotifications.createHTMLNotification(
  'notification.html'  
);

  notification.show();
}

// Conditionally initialize the options.
if (!localStorage.isInitialized) {
  localStorage.isActivated = true;   // The display activation.
  localStorage.frequency = 1;        // The display frequency, in minutes.
  localStorage.isInitialized = true; // The option initialization.
}


if (window.webkitNotifications) {
  // While activated, show notifications at the display frequency.

  if (JSON.parse(localStorage.isActivated)) { show(); }

  var interval = 0; // The display interval, in minutes.


  setInterval(function() {
  interval++;     
  chrome.idle.queryState(15, state); 
  if(localStorage.frequency <= interval && state=="active")
     { show(); 
       interval = 0;
     }

  }, 60000);

}
  • 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-17T14:02:52+00:00Added an answer on June 17, 2026 at 2:02 pm

    Use Chrome.idle API to detect whether browser is active or not and trigger your notifications. I guess you can use a configurable interval to query state and hold off your notifications.

    Reference

    • Chrome.idle

    EDIT 1

    The state in your code is a callback function, not a string!, So change this code

    setInterval(function () {
        chrome.idle.queryState(15, state);
        if (localStorage.frequency <= interval && state == "active") {
            show();
            interval = 0;
        }
    
    }, 60000);
    

    to

    setInterval(function () {
        chrome.idle.queryState(15, function (state) {
            if (localStorage.frequency <= interval && state == "active") {
                show();
                interval = 0;
            }
    
        });
    }, 60000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that is stored locally on my desktop computer. I've made
i have made an installer with izpack for my java desktop application ... after
I made a frame and added a desktop pane (dp_1) to it. Then I
I need to provide webpage (made for desktop browsers) to be usable on mobile
A desktop app (made in Delphi) is started by User A. Let's call it
Does anybody know of a reliable, well-made tool for creating standalone desktop applications complete
i made an .xib file and added my buttons and labels. Then I created
I made a desktop app with the NetBeans platform using Java Swing technology. In
I have just made my first proper little desktop GUI application that basically wraps
I made a very very simple small app to take screenshot of the desktop

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.