Solved

script to close self browser window

Posted on 2004-04-15
9
1,650 Views
Last Modified: 2010-04-06
I am wanting to add a function that automatically closes the browser window when a button is clicked.
Any and all help will be greatly appreciated thanks.

FB
0
Comment
Question by:frankybones
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 10835787
try use window.close() ?

example:

<input type="button" name="Button" value="Close" onclick="window.close()">
0
 
LVL 2

Expert Comment

by:Fataqui
ID: 10836053
Hi


one way.................

button on your main page...............
<center>
 <form>
  <input type='button' onclick="parent.location='/close.php?close=1';" value='Close Me'>
 </form>
</center>


script the button calls..................

<?

if ( ! empty ( $_GET['close']) )
{
      call_close ();

}



function call_close ()
{

echo "<script type='text/javascript' language='JavaScript 1.2'>

      if ( parent.window )
      {
            window.opener=self;
      }

      window.close ();

</script>
";

}


?>

example...................

http://zip.ya-right.net/test.html



Fataqui!
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10836648
use self.close();


function closeCurrentWin( closeSelf){
      if(closeSelf) self.close();
}
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Accepted Solution

by:
YZlat earned 215 total points
ID: 10836655
call this function the following way:

closeCurrentWin( true)
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10836666
<a href="#" onClick="closeCurrentWin(true);">close me</a>
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 10839811
>><a href="#" onClick="closeCurrentWin(true);">close me</a>
It will be always a better pratice to have "return false;" along, right?

<a href="#" onClick="closeCurrentWin(true);return false;">close me</a>
0
 

Author Comment

by:frankybones
ID: 10843479
thank you all for the many examples...please allow me some time to figure out wich one will work best for my application.  Thank you for you time and knowledge.

-FB
0
 

Expert Comment

by:DJArigan
ID: 10871752
This doesn't need to be in a form.

<BUTTON TYPE="button" onClick="self.close();">Close</BUTTON>
0
 

Author Comment

by:frankybones
ID: 10883328
I would like to thank everyone for their efforts and their knowledge once again.
After a lengthy test and trial I made my choice based my application, you all had
right answers.  Thank you,

-FB
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
My first SOAP client. I have constructed the XML message... how to send? 8 72
Removing Flash from Website 6 69
CSS HELP 6 91
What language/protocol is the Angular Chat? 2 86
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

830 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