[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 642
  • Last Modified:

How to close current browser window and open a new browser window with single button click?

I'm having an Anthem button (in my ASP.NET site) on a web form. On this button click i need to close current browser window (i.e. the form) and at the same point i require to open another browser window (.aspx page) which will be showing a .pdf file.

Regards.
0
23-degrees
Asked:
23-degrees
1 Solution
 
hard2u2001Commented:
You can do like:
<button onclick="window.open('http:/\/\www.yahoo.com');window.close();">Open Yahoo and close me</button>

But this works only in ie and in that also it will ask the user wether he wants to close the window or not.
This is because of browser security policies
"Scripts may not close windows that were not opened by script."

Means If your form itself is a Pop-up window then u can use window.open() again and self.close() functions as stated above.
But If the form is in main parent window then it won't close in FF and in IE it will ask user permission.

I hope I am clear.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now