Link to home
Start Free TrialLog in
Avatar of Alpita
Alpita

asked on

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

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

Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

use this function

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

inside the script

document.onkeyup=lookAtTheChild;
document.onmousedown=lookAtTheChild;
document.onmousemove=lookAtTheChild;
Avatar of Alpita
Alpita

ASKER

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

Avatar of Alpita

ASKER

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


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 !!
 
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

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

Avatar of Alpita

ASKER

Hi expert,

It is still opening (refreshing) in same window.

Regards,
Alpita
Avatar of Alpita

ASKER

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
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 ?
call this method in your html body onblur method lookAtTheChild()
Avatar of Alpita

ASKER

Is there any sample code example?
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alpita

ASKER

Thanks a alot