tags:

views:

27

answers:

1

I am asking a small percentage of users on a site if they would take a short survey. If they click 'yes' I would like to close the little pop-up window i have open that is asking them, and launch a new window in the background that comes to the forefront once they leave my domain - or close their browser.

Right now I am using a form:

 <form>
        <input type="button" value="Yes" name="Yes" onclick="javascript:openSurvey();">
        <input type="button" value="No Thanks" name="No" onclick="javascript:closeSurvey();">
</form>

I'm having trouble with this though. I think I can launch the new window OK, but I can't figure out how to close the other window and put the new window in the background. Any tips?

A: 

put the following code in the new window:

window.onload = function()
{
  self.blur();
};
Sparafusile
Cool. Any advice on how to get the window back to the forefront when the domain changes or browser closes?
Peachy
Well, in general you cannot rely on that working. Firefox and Chrome need to be set up explicitly by the user to allow pages to move themselves into the foreground, and Safari will not do it under any circumstances.
Pointy
@Pointy - Yeah, browsers have gotten kinda picky about that with all the popups. @Peachy - I doubt you can explicitly bring another window to the foreground.
Sparafusile
I guess that makes sense as its probably, typically used with nefarious intentions. Guess I'll have to rethink this.
Peachy