By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

Need to close parent window when pop up opens

P: 3
I need to close the parent window which opens a pop up.I have tried the following:


Expand|Select|Wrap|Line Numbers
  1. Response.Write("<script>");
  2. Response.Write("window.open('http://URL_IPadd:8000/Pages/ValidateUser.aspx?JVId=PW0000001&SessionId=1000&IsAdmin=Y&RoleName=Self','PORTFOLIOTRACKER','   scroll=true,resizable=yes,toolbar=no,location=no,directories=no,dependent=no,fullscreen=no,status=yes,left=0,top=0,height='+screen.height-60+',width='+screen.width-5);");
  3. Response.Write("window.opener.close();");
  4. Response.Write("</script>")
Sep 15 '08 #1
Share this Question
Share on Google+
4 Replies


jhardman
Expert 2.5K+
P: 3,405
I need to close the parent window which opens a pop up.I have tried the following:


Response.Write("<script>");
Response.Write("window.open('http://URL_IPadd:8000/Pages/ValidateUser.aspx?JVId=PW0000001&SessionId=1000&Is Admin=Y&RoleName=Self','PORTFOLIOTRACKER',' scroll=true,resizable=yes,toolbar=no,location=no,d irectories=no,dependent=no,fullscreen=no,status=ye s,left=0,top=0,height='+screen.height-60+',width='+screen.width-5);");
Response.Write("window.opener.close();");
Response.Write("</script>")
Even though you are writing this in ASP, it looks like the problem is in the javascript. Let me clarify. You are trying to write this to the client:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. window.open('http://URL_IPadd:8000/Pages/ValidateUser.aspx?JVId=PW0000001&SessionId=1000&IsAdmin=Y&RoleName=Self','PORTFOLIOTRACKER','   scroll=true,resizable=yes,toolbar=no,location=no,directories=no,dependent=no,fullscreen=no,status=yes,left=0,top=0,height='+screen.height-60+',width='+screen.width-5);
  3. window.opener.close();
  4. </script>
This is a javascript function, and unless you are getting an ASP error this is a javascript issue. Have you checked for javascript errors?

Jared
Sep 16 '08 #2

jhardman
Expert 2.5K+
P: 3,405
Oh, I see the problem. You are calling window.opener.close() from the same section of code that opens the new page. window.opener refers to the page that opened the current page. You will need to change that to close the current page, or call window.opener.close() from the next page. Let me know if this helps.

Jared
Sep 16 '08 #3

shweta123
Expert 100+
P: 692
Hi,


Please try this code :

Expand|Select|Wrap|Line Numbers
  1. Response.Write("<script>")
  2. Response.Write("var win =window.open('http://URL_IPadd:8000/Pages/ValidateUser.aspx?JVId=PW0000001&SessionId=1000&IsAdmin=Y&RoleName=Self','PORTFOLIOTRACKER',' scroll=true,resizable=yes,toolbar=no,location=no,d irectories=no,dependent=no,fullscreen=no,status=ye s,left=0,top=0,height='+screen.height-60+',width='+screen.width-5);")
  3. Response.Write("win.opener.close();")
  4. Response.Write("</script>")
Sep 16 '08 #4

rnd me
Expert 100+
P: 427
I am fairly sure that firefox will not allow this happen, regardless of any syntax errors. the ability to close windows/tabs period, is a user-preference in that browser. only pop-ups can be closed that way.

other browsers may follow the same procedures.
Sep 16 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.