Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make my PopUp window stay on top?

Status
Not open for further replies.

mb22

Programmer
Sep 4, 2002
258
US
During opening of Page1.aspx (i.e. durign the PAge Load event) .. if an error occurs I open a popup window PopUp.aspx from the Try-Catch Error block.. but this window does not STAY ON TOP. How do I make it stay on top of Page1.apsx all the time. I don't know if it is bacause .. after Catch block runs ... xeecution returns to FINALLY block which is like back to Page1.aspx.

How can I make Popup.aspx stay up!

Private Sub Page_Load
..
...

Try
..opendb
.. retrive record


catch
Dim strClientCall As String
strClientCall = "<script language=javascript> "
strClientCall &= " var popup = window.open(" & "'genericerror.aspx" & "','_new','left=225,width=575,height=625'" & ");"
strClientCall &= " if(popup) popup.focus(); "
strClientCall &= "</script>"
Response.Write(strClientCall)

Finally
If Not myDataReader Is Nothing Then
myDataReader.Close()
End If

cDAL.CloseDRConnection()
cDAL = Nothing
end try

 
I don't know anything about ASPX, but if you want you can use javasdript to keep the page on top. Do something like this:

<html>
<head>
<title>Test Page</title>
</head>
<body onblur="self.focus()">
<p>Some content here</p>
</body>
</html>

This works in IE and will keep the window on top of the page that opened it. It will not keep the window on top of other browser windows already open.
 
Hi justinbcti,

this keeps indeed the window on top of the page that opened it. However I can go to the page that opened it by clicking the button in the taskbar of windows. I would like to avoid this: so a user has to do the appropiate actions in the window opened on top of the page before he can go back to the original page: any ideas how to accomplish this?
 
In the "parent" window, around where you have the window.open(...) script, try:

Code:
<script>
var popupWin;
var timeoutObject;

function myFunct()
{
 popupWin = window.open(...); //whatever
 keepItOpen();
}

function keepItOpen()
{
 if(!popupWin.closed)
 {
  popupWin.focus();
  timeoutObject = setTimeout("keepItOpen()",100);
 }
 else
  clearTimeout(timeoutObject);
}
</script>

This works for me in IE6. It keeps the popup over the opening window and other browser windows, but not over other application windows.

'hope it helps.

--Dave
 
It sounds like showModalDialog would be your best bet here. I'm pretty sure it's only an option for IE, so if you're looking for cross platformability you'll have to code it yourself.


-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top