Javascript - How do I keep a popup on top - keeps minimizing. Can't use ShowModalDialog.

Hello all,

How can I keep my popup staying on top of my main page.  I have a .net ASPX page and when I call the popup on window.open the popup comes up while the main page is still loading and then it minimizes and the main page has back the focus.  I tried using the window.focus but it doesnt work.  I tried onblur in the body of the popup but that does not allow me to enter user input into my textboxes at all, so I am stuck.  I can't use the showmodaldialog box because I cant refresh it, I hate Microsoft sometimes lol :).  

Any help
sbornstein2Asked:
Who is Participating?
 
Saber37886661Commented:
Hey sbornstein2 I said to put the call to open the window in the onload of the document in my first post. You did do that right? after that the sub window should staty ontop. If not, what browser are you using?
0
 
Saber37886661Commented:
Hi again sbornstein2 :)

I suppose my first thought would to put the popup call in the onload event of the page.

Apart from that, would loading the page in a iframe be ok if the main documents backgound was unclickable?

something like

<div id="selectorPanel" style="z-index: 1000; left: 0px; visibility: visible; position: absolute;
        top: 1000px">
        <table style="height: 455px; background-image: url(../graphics/mesh4.gif); background-repeat: repeat"
            cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr>
                <td valign="middle" align="center">
<iframe src=""></iframe>
                </td>
           </tr>
      </table>
</div>

you can then make it visible/ hidden via some javascript.
0
 
sbornstein2Author Commented:
dont want to use an iframe, everything works great now but i need to get the popup on top.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Saber37886661Commented:
ok here is how to do it
in you parent page put in this code.

<script type="text/javascript">
    cf=false;
    var childWindow;
    function openModel()
    {
        cf=true;
        childWindow = window.open("test2.aspx", "modelWindow", "","");
    }
    function checkFocus()
    {
        if(cf==true)
        {
        try{
        childWindow.FocusMe();
        }catch(e){cf=false}
        }
    }
    window.onfocus = checkFocus;
</script>

on you child window do this:

<script type="text/javascript">
    function FocusMe()
    {
    window.focus();
    }
</script>

And you will have a nice window that stays ontop.
0
 
sbornstein2Author Commented:
doesnt work for me.
0
 
sbornstein2Author Commented:
modal dialog box pops up fine the first time, the second time it always minimizes every time.  It only works the first time and this was not due to the post here it has been doing that it opens in front the first time and then after the first it always minimize while the main page loads up.
0
 
sbornstein2Author Commented:
if the main page is loading data and takes a few seconds the popup is always minimizes after the main page loads completely it seems its a timing thing.  
0
 
siddagrlCommented:
0
 
devanandjhaCommented:
HI,

You can try this on popup page :

<BODY onLoad="self.focus()" onBlur="self.focus()">
This is a quite a simple technique, very often when you open a window and wish to keep it 'on top' of all others until closed.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.