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

  • Home
  • SEARCH
  • 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 1105309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:36:41+00:00 2026-05-17T01:36:41+00:00

Note that this relates to focus and blur events on a window, not on

  • 0

Note that this relates to focus and blur events on a window, not on form fields.

I’m loading a document in a pop-up window, and it includes the following code:

<script type="text/javascript">
window.onblur = function(){ document.title="BLURRED"; }
window.onfocus= function(){ document.title="FOCUSED"; }
</script>

These functions are temporary, for testing. I’d hoped to use these events to set a flag indicating the window state; I’m doing a chat app, and if messages come in when it’s minimized I’ll do some attention-getting title changes. If they don’t cancel when the window gets focus, though, they’ll just be annoying.

Onload, I also put focus into a textarea. (Not sure if that makes any difference.)

IE7 (I don’t have another version handy) seems to recognise the window.onblur but not the window.onfocus. Opera 10 is just downright strange.

Here’s what happens in the browsers I have. I launch the pop-up window by clicking on the link in the parent, then go through several minimize-restore cycles by clicking the popup’s button on the (Windows XP) taskbar:

Safari 4:

  • Open window: Document opens with original title
  • Minimize: Title changes to "BLURRED"
  • Restore: Title changes to "FOCUSED"

This is what I expected to happen.

Firefox 3.5:

  • Open window: Document opens with original title, then changes to "FOCUSED"
  • Minimize: Title changes to "BLURRED"
  • Restore: Title changes to "FOCUSED"

The onfocus onload is a bit of a surprise, but not a problem.

IE7:

  • Open window: Document opens with original title
  • Minimize: Title changes to "BLURRED"
  • Restore: Title does not change, no matter how many times I toggle

What happened to onfocus?

Opera 10.5

  • Open window: Document opens with original title, but in another tab, not pop-up

Sometimes…

  • Minimize: Title changes to "BLURRED"
  • Restore: Title changes to "FOCUSED"

Sometimes…

  • Minimize: Title changes to "BLURRED" then "FOCUSED"
  • Restore: Title does not change

Okay, this is just plain weird…

I’m open to other approaches, but I’d really like to understand what’s going on here, in plain old Javascript – so please don’t give a jQuery answer unless there really is no other way around this.

  • 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-17T01:36:41+00:00Added an answer on May 17, 2026 at 1:36 am

    onfocus and onblur are buggy on the window object in IE. The alternative is to use the propagating onfocusin and onfocusout events:

    function focusin() { document.title="BLURRED"; }
    function focusout() { document.title="FOCUSED"; }
    
    if ("onfocusin" in document)
        document.onfocusin = focusin,
        document.onfocusout = focusout;
    else
        window.onblur = focousout,
        window.onfocus= focusin;
    

    I’ve set up an example for you here.

    focusin and focusout, unlike focus and blur, are propagating events; they will fire for elements in the page and bubble upwards. You will need to check the event.srcElement or event.target if you don’t want to act on this event for all elements on the page.

    As for Opera, “strange” is one word you could use. The version on my machine will not fire the blur or focus events on the window for me. Hopefully someone else can offer you a solution for that.

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

Sidebar

Related Questions

Note that this function does not have a { and } body. Just a
Has anyone seen this type of IE display problem? Example http://xs133.xs.to/xs133/08465/ie_problem910.jpg.xs.jpg Note that it
Let's say I have a simple stored procedure that looks like this (note: this
Note: I found this Creating a Word Doc in C#.NET , but that is
Note that I am not asking which to choose (MVC or MVP), but rather
We're seeing the error message ORA-00936 Missing Expression for the following SQL: Note that
How do I load a Python module given its full path? Note that the
The attached screenshot is from OS X/Firefox 3. Note that the center tab (an
When I go to create my status bar overlay, I note that I can
Can someone explain me the reason of overflow in variable a? Note that b

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.