What are window.onblur/window.onfocus used for ????

Please help !
Thanx

Member Avatar for stbuchok

When the window has focus and loses focus.

Member Avatar for stbuchok

Sorry, when the window receives focus and when it loses focus.

Sorry, when the window receives focus and when it loses focus.

I am sorry !
I could not get meaning of 'focus' mainly in case of Javascript ....
Moreover what kind of focus is it talking about ??

I would be glad if you could elaborate.

Thanx

http://www.thefreedictionary.com/focus

That's the best I can do.

Really !
Is that it ???
:-O
You were talking about this "focus" (optics) .... !
Well .... I guess I have to explore a bit more ....
Thanks anyway ....

Member Avatar for stbuchok

OK, seriously!? Read all of them.

To converge on or toward a central point of focus; be focused.
To concentrate attention or energy.

If your not going to read an answer don't ask the question.

What are window.onblur/window.onfocus used for ????

Please help !
Thanx

The window: onblur and onfocus are events of a browser window which were used to determine if the app is in front or behind another app.

This way web jerks were able to detect when you switched to another window and bring it back in, on top of the current and continue to annoy you.

I am sorry !
I could not get meaning of 'focus' mainly in case of Javascript ....
Moreover what kind of focus is it talking about ??

I would be glad if you could elaborate.

Various elements in a browser page (including the page itself) take "focus" when they are clicked or visited with the tab key.

Two event types are associated with "focus":

  • onfocus: an event that fires when focus is gained
  • onblur: an event that fires when focus is lost

As with all events, javascript provides the means to attach custom functionality to elements by attaching event handlers (javascript functions) to them.

Much of the skill in writing interactive web pages lies in knowing how to write event handlers.

Airshow

Whatever you click your mouse on has focus. Clicking on something different causes the focus to blur.
onfocus was more populare when netscape 4 was around because it didn't recognise onclick.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <frameset cols="150,*">
      <frame name="toc"
             src="/ajax_tut.htm"
             onfocus='myFocusFunc()'
             marginwidth="1" marginheight="1" scrolling="AUTO">
      <frame name="body"
             src="/headInfo.htm"
             marginwidth="10" marginheight="5" scrolling="AUTO">
    </frameset>
    <head>
       <title>Focus !</title>
       <script type="text/javascript">
           function myFocusFunc() {
               alert('This means you are focusing here !');
           }
       </script>
    </head>
    <body>
        <p>
            &nbsp;</p>
    </body>
</html>

I have tried to use onfocus ....
so that when I click on the window the function gets invoked !
Still it is doing what is intended !!!!
Please help !

Member Avatar for stbuchok

Why do you have a frameset outside the body tag and above the head tag? Also do the onfocus stuff inside the html page that is being loaded in the frame not on the frame or frameset. Frame and frameset support onload and I believe onunload but no other events.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.