?
Solved

script to close self browser window

Posted on 2004-04-15
9
Medium Priority
?
1,654 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 53

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
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.

 
LVL 35

Accepted Solution

by:
YZlat earned 860 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 53

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

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.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

718 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