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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Self close () 2

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
How can I close on a pop-up after I click on it?
[tt]"A Successful man is one who can build a firm foundation with the bricks that others throw at him"[/tt]
[noevil]
 
In IE you could add an onClick event handler to the BODY tag. I doubt this is Netscape friendly.

Code:
<BODY ... onclick=&quot;self.close()&quot;>
Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Hi Tony,

Put this in your main page to open the popup.html:

<script language=&quot;javascript&quot;>
function OpenThisWindow()
{
window.open('popup.html', 'windowname', 'width=300, height=300')
}
</script>

<a href=&quot;javascript:OpenThisWindow()&quot;>open a popup</a>

------------------------------------------------

this is an example for the popup.html file:

<html>
<head>
<title>Just testing.....</title>
</head>
<body onclick=&quot;self.close()&quot;>

text in the popup

</body>
</html>

you can also use the onmousedown event instead of onclick

Hope this helps,
Erik




<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Yes, IE is what we use company wide. Can I also include a link to this Self.close() ??

for example:
<A href=&quot;info.asp&quot;><FONT size=&quot;2&quot;>Click
here for more info</FONT></A>

How can I use the Self.Close() code with my above code?
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Just have the link call the javascript method:
Code:
<A href=&quot;javascript: self.close()&quot;>Click here to close</A>

This link should work on all browsers (just incase you were courious) [yoda] Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
This makes sense to me. Except

<script language=&quot;javascript&quot;>
function OpenThisWindow()
{
window.open(' popup.html', 'windowname', 'width=300, height=300')
}
</script>

This window contains text with a link to follow and I need to close it after the link has been clicked.
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
So you want to both follow the link and close the window? Where is the link supposed to load (which window)?

There are many ways to handle this, so let me know your specific details and I can help you craft the correct solution.
Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Try:

<A href=&quot;javascript: window.opener.location.href='nextlink.htm'; self.close()&quot;>Click here to close</A>
 
[tt]Thanks to all for your responses. I was able to use Boomerang's

<body onclick=&quot;self.close()&quot;>
which allows me to not only click on the link but also close the pop-up.

Thanks again.
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top