Solved

avoing overriding pop up windows

Posted on 2011-09-16
8
218 Views
Last Modified: 2012-06-21
Hi,
  I have a first pop up window in javascript and from first popup window, I need to open second popup window. When I open second popup window, it is overriding first pop up window.
 I don't want to override first popup window. Please let me know how can I do it.

Thank you
0
Comment
Question by:Sthokala
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
check this simple example, it works for me here
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>

<BODY>
	<a href="javascript:window.open(location.href)">Open window</a>
</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:Sthokala
Comment Utility
Hi Gurvinder,
  Thank you for your reply. I want to open a popup from another popup.

Thank you
0
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
please share that code which is not working for you
0
 

Author Comment

by:Sthokala
Comment Utility
Please find the attached code.

Thank you
a.jsp has code like below
function showLogin(){
var adjustHeight = 40;
	  var adjustWidth = 15;
	        var height = screen.availHeight-adjustHeight;
	        var width = screen.availWidth-adjustWidth;        
	        var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes,scrollbars=yes";        
	var strURL = "login.jsp";
	var win = window.open(strURL,"login",winProps);
	win.focus();
	
}

Login.jsp has code like beow

function postLogin(){
	var adjustHeight = 40;
	  var adjustWidth = 15;
	        var height = screen.availHeight-adjustHeight;
	        var width = screen.availWidth-adjustWidth;        
	        var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes,scrollbars=yes";        
	        var userName = document.getElementById("userName").value;
	        var password = document.getElementById("password").value;
	        var strURL = "loginbean.jsp?userName=" + userName+"&password="+password+"&loginType="+"cpoeLogin";
		var winPop = window.open(strURL,"theWin",winProps);
		
		
	}

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
on line 25, try changing:

var winPop = window.open(strURL,"theWin",winProps);

to:
var winPop = window.open(strURL,"_blank",winProps);

OR
var winPop = window.open(strURL,undefined,winProps);
0
 
LVL 18

Expert Comment

by:nap0leon
Comment Utility
/agree with hielo
If you explicitly tell the code the name of the window you are popping, the new stuff will go to that window.

using "_blank" normally works.

If you encounter issues with _blank, use a random number generator and pass window.open the random number as the name.
0
 

Author Comment

by:Sthokala
Comment Utility
Thank you..exactly what I wanted.
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
>>exactly what I wanted.
Did both work as expected across browsers? Just curious.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

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

10 Experts available now in Live!

Get 1:1 Help Now