?
Solved

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

Posted on 2009-12-20
9
Medium Priority
?
481 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:sbornstein2
9 Comments
 
LVL 3

Expert Comment

by:Saber37886661
ID: 26093394
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
 

Author Comment

by:sbornstein2
ID: 26093419
dont want to use an iframe, everything works great now but i need to get the popup on top.
0
 
LVL 3

Expert Comment

by:Saber37886661
ID: 26093461
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sbornstein2
ID: 26093569
doesnt work for me.
0
 

Author Comment

by:sbornstein2
ID: 26093583
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
 

Author Comment

by:sbornstein2
ID: 26093600
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
 
LVL 5

Expert Comment

by:siddagrl
ID: 26093607
0
 

Expert Comment

by:devanandjha
ID: 26093798
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
 
LVL 3

Accepted Solution

by:
Saber37886661 earned 2000 total points
ID: 26094127
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question