SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to know whether the active desktop window is browser

    Can anybody help on how to know whether the active (topmost) desktop window is the browser displaying my web page.
    Precisely, I want to know whether the user is seeing my page, or the page is opened in the background.
    I tried 'focus', 'blur' events on DOM object 'window'. It is not solving my problem.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,269
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    top window

    Hi balaji_d, welcome to the forums

    I think if you can explain what you are trying to do, that is, why you want to know if the window is in top, there should be a way to do this without having to know if it's on top or not. In other words, why would the information make a difference?

  3. #3
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mittineague,
    I am implementing a google chat like thing. I want to play some sound (similar to what gchat does), when some message from the other users comes. This should happen only when the browser window/tab is not the one which is being viewed by the user. I think this information is needed in the implementation of Google Adsense too.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,269
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    notify

    Yes, this could be a problem. I don't know about adsense, but I have seen little pop-up notices that play a sound when some event occurs ie. (new email, IM, RSS feed, etc) in desktop applications.
    AFAIK, sound isn't dependent on whether the page is on top or not. But of course using pop-ups would be problematic with the wide use of blockers these days, and if you only want the sound to attract the user when they're not actively chatting, ...
    If this is a web feature (not a desktop app), I think the best thing to do would have users opt in for the feature. Something like "Notify me of new activity", and have an alert() that lets them know they should check out the chat. Either that or play the sound top or not.
    Both ways would be a distraction. the alert most likely with a higher annoyance level. Why not offer both as choices?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •