Solved

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

Posted on 2011-02-27
14
384 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
Comment Utility
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
Comment Utility
or alone use this

inside the script

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

Author Comment

by:Alpita
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
 
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Alpita
Comment Utility
Hi expert,

It is still opening (refreshing) in same window.

Regards,
Alpita
0
 

Author Comment

by:Alpita
Comment Utility
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
Comment Utility
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
Comment Utility
call this method in your html body onblur method lookAtTheChild()
0
 

Author Comment

by:Alpita
Comment Utility
Is there any sample code example?
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 500 total points
Comment Utility
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
Comment Utility
Thanks a alot
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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