Solved

avoing overriding pop up windows

Posted on 2011-09-16
8
224 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
ID: 36550935
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
ID: 36551112
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
ID: 36551117
please share that code which is not working for you
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:Sthokala
ID: 36551324
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
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 36551553
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
ID: 36551570
/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
ID: 36551695
Thank you..exactly what I wanted.
0
 
LVL 82

Expert Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

815 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

12 Experts available now in Live!

Get 1:1 Help Now