|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Close POP-UP
I have several pages on my site that link to pop-ups with different information.
I am looking for somekind of script that makes it so that if you click outside of the pop-up area. The pop-up is closed. I saw this once done in a site and can't remember what site it was. All I know was that when you clicked in the page that generated the pop-up, the pop-up would close. Any ideas? |
|
#2
|
|||
|
|||
|
RE: Close POP-UP
use an onblur event in the body tag of the page loaded in the popup...
onblur="document.self.close()" if I remember correctly though, even if to click the page that loads in the popup the popup will close. Play around with it to see if it will work for you. |
|
#3
|
|||
|
|||
|
RE: Close POP-UP
what about in the main page, something like
<body onClick="popup.window.close()"> although if you haven't opened the popup yet, it'll probably give you a JS error. <body onClick="if(popup)popup.window.close()"> might work, but i'm not sure... |
|
#4
|
|||
|
|||
|
RE: Close POP-UP
Tried it, and it unfortunately doesn't work.
I know this is possible because I once saw it on a site. But, can't for the life of me remember which site it was. Any other ideas? |
|
#5
|
|||
|
|||
|
RE: Close POP-UP
okay, i think i've got it.
<a href="#" onClick="someName = window.open('page','name','etc');">open window</a> <a href="#" onClick="someName.close();">close window</a> does that make sense? again, there's still a problem with if the "someName" window hasn't been opened. this works in IE, but my school doesn't have firefox so i couldn't test it in that. |
|
#6
|
|||
|
|||
|
RE: Close POP-UP
I just tested my earlier suggestion and your right, it did not work...because I made a mistake!!. try this in the body tag if the popup page.
onblur="self.close()" I tested it in in IE and Firefox and it worked for both. The window closes if the main window (or any other window for that fact) gets focus. |
|
#7
|
|||
|
|||
|
RE: Close POP-UP
Cool. Works now. Thanks a million!
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Close POP-UP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|