• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3935
  • Last Modified:

window.open yes, but 'bring to front' of all windows?

Ok.. I'm starting to think this isn't possible but...

I have written a javascript counter that keeps track of how long a user has been idle from using an ASP application I wrote. When the counter reaches 0 the script automatically opens a new window prompting them to either logout or stay active. If they don't respond in 2 minutes it will automatically log them out.

Ok.. now the problem. Everything works fine but the window doesn't open over top of all windows the user has open. Some users are complaining that they don't see it open up on the taskbar and it logs them out when they don't want to be logged out.

I have added a focus() to the window name being called by the opener but it just brings the window into focus and on top of the user is currently viewing the browser window that opened the window.

Is there a way to bring that browser window to the front of all applications running in windows?
2 Solutions
Not really unless you do this;


but that means it will stay on top and the user can't access windows until this one is closed.

OverSurgeAuthor Commented:
That would be fine with me. It's just a quick ASP page that says continue or not.
But I can't get the opening popup window into focus for the javascript code to take effect. That still requires the prompt window to come into focus on top of the other windows so I can keep there focus on it.
Do the following:

<body onLoad=window.focus()>

That will bring it into focus when the page renders.

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

You can use both:

<body onload="window.focus();" onblur="window.focus();">

which will bring focus to the window when it opens, and keep it there until it's closed.
Which is pretty much what I have....

However it will still be possible for someone to bury the browser under word, outlook, excel and etc.

I am afraid you will have to live with it.  .focus() cannot really put you in a true 'always on top' position, it only puts you on top of other browser windows opened by the current browser invocation.

How would you like it if you, while busy beawering away at Word, looked up to see that god knows how much of your work had been intercepted by a strange window that suddenly started stealing your keyboard input?

You need some really heavy privilidges to do that. And even if you have the priviledge, think twice.

regards JakobA
OverSurgeAuthor Commented:
Well as I said.. I didn't think it would be possible but I needed verification right away so I could tell my boss to tell the users "can't happen". As JakobA stated, I didn't think permission levels of that amount would be good. The points of course would go to the first person who verified all my thoughts for me. Though other suggested using focus() to its limitations, I already recognized this option with it's limitations. fritz_the_blank did first mention that it would still be buried under word, excel, etc, but JakobA stated the exact facts I was looking for in bring truly 'always on top' position and the security and permision limitations. So I'm going to split points between fritz & JakobA. I do thank everyone else for there input.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now