Solved

Keep popup window in focus - EASY.

Posted on 2004-10-14
14
475 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Pigdogmonster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 4
14 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 30 total points
ID: 12307204
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
 
LVL 33

Expert Comment

by:sajuks
ID: 12307212
0
 

Author Comment

by:Pigdogmonster
ID: 12307549
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
Industry Leaders: 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!

 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12307966
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
 

Author Comment

by:Pigdogmonster
ID: 12308163
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
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12309197
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
 
LVL 33

Expert Comment

by:sajuks
ID: 12309577

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
 

Author Comment

by:Pigdogmonster
ID: 12317003
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
 
LVL 33

Expert Comment

by:sajuks
ID: 12317141

  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
 

Author Comment

by:Pigdogmonster
ID: 12320930
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
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12322553
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
 
LVL 33

Expert Comment

by:sajuks
ID: 12322658
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
 

Author Comment

by:Pigdogmonster
ID: 12336901
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
 
LVL 13

Assisted Solution

by:cLFlaVA
cLFlaVA earned 20 total points
ID: 12340586
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

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC -Update model when click on <li> element 29 66
Can't get js code to execute 8 30
arrays and radio buttons 10 36
Glitching Slide Show 19 26
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

740 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