Keep popup window in focus - EASY.

Hi,

I'm sure there is script out there to do this..

I have a page that has a simple link that opens is a new window..
<head>

<script>
function openWindow(url)
  {
      var w = window.open(url,"popupReport","width=460,height=450,resizable=yes");
      
        }
</script>
</head>


<a href="JavaScript:openWindow('window.asp')">View Basic data for:-(Click)</a>

What I want to do is when the smaller popup window appears it contains info that the user needs to fill out data on the main form so I want it to stay on top all the time until the user closes it.

At the moment if I click the main window the popup goes to the back and this can annoy the user as they have to go and find the window each time.


Many thanks

Stu
PigdogmonsterAsked:
Who is Participating?
 
sajuksCommented:
first page
function openWindow(url)
  {
     var w= window.open(url,"popupReport","width=460,height=450,resizable=yes");
     w.focus();
 
       }

in the second page (popup)have
<body  onBlur="window.focus();">
</body>
0
 
sajuksCommented:
0
 
PigdogmonsterAuthor Commented:
thanks Sajuks,

I will try this:-


function showHelp(theUrl) {
   if (document.all) WinHandle = window.showModalDialog(theUrl,'arguments','dialogWidth=200,dialogHeight=400')
   else WinHandle = window.open(theUrl,'newwin','width=200,height=400,alwaysRaised');
}


How do I incorporate this with my existing code?

first page
function openWindow(url)
  {
     var w= window.open(url,"popupReport","width=460,height=450,resizable=yes");
     w.focus();
 
       }

in the second page (popup)have
<body  onBlur="window.focus();">
</body>
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
cLFlaVACommented:
sajuks, fyi-

the body onblur event won't be your friend if you have a textbox or other form element in there.  As soon as you set focus to the text box, the body loses focus, and so re-sets focus to the body, thus never enabling the user to interact with the textbox.
0
 
PigdogmonsterAuthor Commented:
yeah, just noticed that :-(

The popup window contains information that helps the user fill out the textbox's on the form.

It works great but its  shame you cant enter text on the other form.

Do you know if its possible?
0
 
cLFlaVACommented:
The only and best way would be using the modal window, unfortunately it only works in IE.

I have not yet found a way to do this with JavaScript, after several attempts at solving this exact problem for many people.
0
 
sajuksCommented:

modal window would be the only possible way but as already pointed out in my second post its IE only.
cLFlaVA my bad i'd forgotten that it wouldnt be possible to enter in the popup. Thanks for the correction
0
 
PigdogmonsterAuthor Commented:
Thanks Guys,

Luckily for me this site will only run on IE so I dont have an issue with using any other browsers.

Do you have the syntax for a modal window?
0
 
sajuksCommented:

  if (document.all) WinHandle = window.showModalDialog(theUrl,'arguments','dialogWidth=200,dialogHeight=400')
   else WinHandle = window.open(theUrl,'newwin','width=200,height=400,alwaysRaised');

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodaldialog.asp
0
 
PigdogmonsterAuthor Commented:
hi guys,

Just tried the modal window and that has the same problem - when the popup windowis open you cannot complete any information on the other windows!!

Do you think there is any other way round this?
0
 
cLFlaVACommented:
I don't understand.  Your original request was, how do I keep a popup window focused until the user closes it.  Now, you're saying you DON'T want the window to have focus constantly.  You instead want the user to be able to access the parent window.

You can't have both scenarios, you'll have to choose only one.
0
 
sajuksCommented:
a modal window is like a response window ( alert box ) . unless you dont specify some action it wil lremain . thats what you wanted wasnt it?
0
 
PigdogmonsterAuthor Commented:
Hi gents,

My request has always been the same but I think I have used the incorrect terminolgy when describing exaclty what I want! :-]

To have a popup window that stays focused but you can still enter data in the main window.

I just didnt realise it would'nt be possible to have the popup "on top"  and have be able to complete data in the main window.

The popup window is soley for displaying information that helps the user fill in the main form.

So the popup wondow does not have to be in focus but just not go the the back when the user clicks in the same window.

Sorry for any confusion.
0
 
cLFlaVACommented:
Nope, no way to keep the window on top while typing in another window behind it.  Best you can do is resize them and place them next to eachother.
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.