Solved

how i can bring opened popup to front when multiple popups opened?

Posted on 2011-02-27
14
387 Views
Last Modified: 2012-05-11
Hi expert,
Please help me.
I have two jsp's  one.jsp , two.jsp.

In one.jsp i have few commandHelp links say commandHelp1, commandHelp2....

when i click commandHelp1 from one.jsp , the control goes to two.jsp with some command parameters.

I am using window.open from one.jsp to two.jsp(in which .swf is embedded) which opens flex page in two.jsp

so now, when i click commandHelp2 from one.jsp ,the current window will disappear and opens in another window.

Could you please let me know how i can see two command windows at a time  and also when i click commandHelp1

Link, the opened commandHelp1 Link should come front.

I mean i want to see multiple windows(some kind of pop ups),and when i click particular opened command window

that should come front.


Right now , my code in one.jsp is
----------------------------------

var oneWin = '';
function open_window(urlString, winprops, winName) {
    if (!oneWin.closed && oneWin.location) {
        oneWin.location.href = urlString;
    } else {
       //oneWin=window.open(urlString,'IPAGDetail',winprops);
       oneWin=window.open(urlString,winName,winprops);
       if (!oneWin.opener){
           oneWin.opener = self;
       }
    }

    if (window.focus) {
        oneWin.focus();
    }
    return;
}

function command_help(id,name,type,c_type)
{
  var winprops = 'height=700,width=718,top=0,left=0,resizable=yes,scrollbars=yes,status=no';
  var urlString = "/flexappl/helpView/two.jsp?Id= " + id + "&Name=" + name + "&Type=" + type + "&cardT=" + c_type;
  open_window(urlString, winprops, 'helpView');
}

Open in new window

0
Comment
Question by:Alpita
  • 8
  • 6
14 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34995210
use this function

function lookAtTheChild()
{
      try{newwindow.focus();}catch(e){};
}
document.onkeyup=lookAtTheChild;
document.onmousedown=lookAtTheChild;
document.onmousemove=lookAtTheChild;
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34995257
or alone use this

inside the script

document.onkeyup=lookAtTheChild;
document.onmousedown=lookAtTheChild;
document.onmousemove=lookAtTheChild;
0
 

Author Comment

by:Alpita
ID: 35000548
Hi Expert,
I added your code in  script block. But i do not see any change(not opening new window for commandHelp2 ). Could you please let me know where i am wrong?


I modified like this  in one.jsp:
----------------------------------

var oneWin = '';
function open_window(urlString, winprops, winName) {
    if (!oneWin.closed && oneWin.location) {
        oneWin.location.href = urlString;
    } else {
       oneWin=window.open(urlString,winName,winprops);
       if (!oneWin.opener){
           oneWin.opener = self;
       }
    }

    if (window.focus) {
       // oneWin.focus();
      document.onkeyup=lookAtTheChild;
      document.onmousedown=lookAtTheChild;
      document.onmousemove=lookAtTheChild; 
    }
    return;
}

function lookAtTheChild()
{
      try{newwindow.focus();}catch(e){};
}

function command_help(id,name,type,c_type)
{
  var winprops = 'height=700,width=718,top=0,left=0,resizable=yes,scrollbars=yes,status=no';
  var urlString = "/flexappl/helpView/two.jsp?Id= " + id + "&Name=" + name + "&Type=" + type + "&cardT=" + c_type;
  open_window(urlString, winprops, 'helpView');
}

Open in new window

0
 

Author Comment

by:Alpita
ID: 35003722
Hi Expert,

I think i might have confused you.
The issue is , it is opening in same window. The requirement is to open in multiple windows instead of one.

Regards,
Alpita


0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35004212
I thought u want foucs only ur child window ! not the parent window !!  

the above code help you is

its foucus only popup window you cant go to parent with out closing that !!  so it may be useful to slove ur issue !!
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35004227
 
I modified like this  in one.jsp:  
----------------------------------  
  
var oneWin = '';  
function open_window(urlString, winprops, winName) {  
    if (!oneWin.closed && oneWin.location) {  
        oneWin.location.href = urlString;  
    } else {  
       oneWin=window.open(urlString,winName,winprops);  
       if (!oneWin.opener){  
           oneWin.opener = self;  
       }  
    }  
  
    if (window.focus) {  
       // oneWin.focus();  
         
    }  
    return;  
}  
  
function lookAtTheChild()  
{  
      try{newwindow.focus();}catch(e){};  
}  
document.onkeyup=lookAtTheChild;  
      document.onmousedown=lookAtTheChild;  
      document.onmousemove=lookAtTheChild;
  
function command_help(id,name,type,c_type)  
{  
  var winprops = 'height=700,width=718,top=0,left=0,resizable=yes,scrollbars=yes,status=no';  
  var urlString = "/flexappl/helpView/two.jsp?Id= " + id + "&Name=" + name + "&Type=" + type + "&cardT=" + c_type;  
  open_window(urlString, winprops, 'helpView');  
}

Open in new window

0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35004244
Or the simple way is jsut fous in the popup window !!

put  this inside the else condition

   if (window.focus) {    
        oneWin.focus();    
           
    }

 
var oneWin = '';    
function open_window(urlString, winprops, winName) {    
    if (!oneWin.closed && oneWin.location) {    
        oneWin.location.href = urlString;    
    } else {    
       oneWin=window.open(urlString,winName,winprops);  
       if (window.focus) {    
              oneWin.focus();    
         }    
  
       if (!oneWin.opener){    
           oneWin.opener = self;    
       }    
    }    
    
        return;    
}

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Alpita
ID: 35006935
Hi expert,

It is still opening (refreshing) in same window.

Regards,
Alpita
0
 

Author Comment

by:Alpita
ID: 35028833
I got some information like if we give winname attribute ' ' in window.open(), then opens in multiple windows.

I tried , but not solved my problem.
Any ideas?

Regards,
Alpita
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35029329
you need that only right ! you need not open multiple window(popup) !

if you press another popup means it will open a in same winodw ! thats  all . what you experted other than this ?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35029345
call this method in your html body onblur method lookAtTheChild()
0
 

Author Comment

by:Alpita
ID: 35162423
Is there any sample code example?
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 500 total points
ID: 35162904
Try this
var oneWin = '';      
function open_window(urlString, winprops, winName) {      
    if (!oneWin.closed && oneWin.location) {      
        oneWin.location.href = urlString;      
    } else {      
       oneWin=window.open(urlString,winName,winprops);    
       if (window.focus) {      
              oneWin.focus();      
         }      
    
        
    }      
      
        return;      
} 


function lookAtTheChild()    
{    
      try{newwindow.focus();}catch(e){};    
}    
document.onkeyup=lookAtTheChild;    
      document.onmousedown=lookAtTheChild;    
      document.onmousemove=lookAtTheChild

Open in new window

0
 

Author Closing Comment

by:Alpita
ID: 35338208
Thanks a alot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference between member and local variables. 29 126
nested if has else if 13 92
Looking for some programs to resell or buy source codes 1 75
withoutString  challenge 40 177
With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now