Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close window script 2

Status
Not open for further replies.

ccs2

Instructor
Oct 8, 2003
37
GB
I need a little java script attached to 'Close Window' text on a web page which will do just that, rather than require the user to use the cross button in the window corner. Can anyone help?

ccs
 
Here you go:

[tt]<a href="#" onclick="window.close();">Close Window</a>[/tt]

*cLFlaVA
----------------------------
When will I be able to see what other members can see about myself? It's been like, a freakin' month already!
 
One option:

<a href="javascript:void(0)" onclick="opener=self;window.close();">Close Window</a>

'hope that helps.

--Dave
 
<a href="#" onClick="window.close();">Close window</a>
This will provoke a permissions prompt from IE, at least. To circumvent that, try:

Code:
<script type="text/javascript">
<!--
function closeNoPrompt()
{
  top.opener = self;
  top.window.close();
}
-->
</script>
...
<a href="#" onClick="closeNoPrompt()">Close window</a>

--Chessbot

The program didn't do anything wrong; it did exactly what you told it to!
 
Oops... mistake in mine:

<a href="javascript:void(0)" onclick="window.opener=self;window.close();">Close Window</a>

--Dave
 
As I've found out (the hard way), you have to be careful where you use that security alert workaround. Some people or groups of people consider it malicious in that it avoids displaying a security alert to a user.

The workaround, additionally, will only function in IE.

*cLFlaVA
----------------------------
When will I be able to see what other members can see about myself? It's been like, a freakin' month already!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top