/    Sign up×
Community /Pin to ProfileBookmark

Detect Window Close

after making a call to window.open
i would like to detect when the popUp window is closed

i have a Close button on the screen
so onClick, it will detect

but if the user click on the Close in the titlebar,
my code doesnt account for that

i have given the window a name,
eg, newPopUp
and tried checking for the existence of the window
but it doesnt seem to work…..

eg. when opening the window

[CODE]window.open(‘pop21.htm’,’cam1′,’width=640,height=550,scrolling=no,titlebar=no’)
winClosed=true
top.frames[‘camera1’].location.href = “about:blank”[/CODE]

and closing

[CODE]function winClose() {
opener.top.camera1.location = ‘test21.htm’
window.close()
}[/CODE]

[CODE]if (winClosed==true && !cam1) {
top.camera1.location = ‘test21.htm’
}[/CODE]

the winClose function is fine
but it will not detect if the window is closed through the X on the titlebar

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gigszFeb 20.2007 — <body onbeforeunload="winClose();"> =)
Copy linkTweet thisAlerts:
@totallychibiauthorFeb 20.2007 — thanks

works great!!

.. i seem to have posted twice accidentally ..
×

Success!

Help @totallychibi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...