Page coming into focus event

S

Steve Swift

I've asked this before, and last time the answer was "not possible".
Maybe some more clever people are hanging around this time:

Is there a way to trigger a routine when a page gets the "focus"? I'm
thinking of when you switch to a page in a tabbed browser.

Don't ask me what I'm going to do in such an event. It is no more
interesting than knowing what I plan to do when I leave my house. (Put
the milk bottles out)
 
S

Stevo

Steve said:
I've asked this before, and last time the answer was "not possible".
Maybe some more clever people are hanging around this time:

Is there a way to trigger a routine when a page gets the "focus"? I'm
thinking of when you switch to a page in a tabbed browser.

Don't ask me what I'm going to do in such an event. It is no more
interesting than knowing what I plan to do when I leave my house. (Put
the milk bottles out)

My first thought turned to mousemove events. Not sure if you get them
when your window doesn't have focus. Not forgetting of course that the
window can still be visible even if it doesn't have current focus.
 
S

SAM

Steve Swift a écrit :
Is there a way to trigger a routine when a page gets the "focus"? I'm
thinking of when you switch to a page in a tabbed browser.

It was a time where :

<body onfocus="putOut('milk bottles');">

worked

Seems stil working with my Firefox
 
S

SAM

Stevo a écrit :
My first thought turned to mousemove events. Not sure if you get them
when your window doesn't have focus. Not forgetting of course that the
window can still be visible even if it doesn't have current focus.


visible != focus

so ... no importance



window.onfocus = function() { alert('focus'); };
</script>

or :
<body onfocus="alert('focus');">


Very funny with my Opera :-(
 
S

Steve Swift

Is there a way to trigger a routine when a page gets the "focus"? I'm
thinking of when you switch to a page in a tabbed browser.

In the Opera Community forums I was pointed at window.onfocus which is
just what I was looking for.

The fact that I can't make it do what I want it to is my problem. I
think there are conditions when the event triggers before the page has
loaded, so attempting to manipulate controls which are not yet present
fails.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top