sbornstein2
asked on
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
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
ASKER
dont want to use an iframe, everything works great now but i need to get the popup on top.
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.
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.
ASKER
doesnt work for me.
ASKER
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.
ASKER
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.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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)
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.