[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

Closing a browser window from a javascript link

I am trying to set up a link to close a browser window using: onClick="javascript:window.close();

The window is initially opened from the main page and displays a signup form. When the form is sent a confirmation page appears and it is this page that has the button to close the window using the javascript function above.

The javascript works if I open the window directly to display the confirmation page but it is not working when the confirmation page is called from the original page with the form.

Could someone point me in the right direction please.
0
grigorovsky
Asked:
grigorovsky
  • 4
  • 3
1 Solution
 
MrunalCommented:
Hi
Can you post your code? This can help us to resolve your problem quickly.
0
 
Barry62Commented:
Use self.close()

<a href="" onclick="self.close();return false;";>Close This window</a>
0
 
grigorovskyAuthor Commented:
Self.close() doesn't work either but I have now discovered that parent.close() does.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Barry62Commented:
hmm.  I thought you were wanting the button on the confirmation window to close itself, not the main form window.
0
 
grigorovskyAuthor Commented:
This works:

<a href="#" class="button" onClick="javascript:parent.close();">Close Window</a>

These don't:

<a href="#" class="button" onClick="javascript:self.close();">Close Window</a>
<a href="#" class="button" onClick="javascript:window.close();">Close Window</a>
0
 
grigorovskyAuthor Commented:
The confirmation page appears in the same window as the sign up form and has the close button at the bottom. Apologies if that wasn't clear from my original post.

I originally had the confirmation page script set to window.close() and this didn't work. It appears that parent.close() is the correct method in this situation.
0
 
Barry62Commented:
Yes, that would be correct in your situation.  Sorry for the misunderstanding.
0
 
grigorovskyAuthor Commented:
My own solution was the correct one in this situation.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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