开发者

How can I capture window close event?

I have Ajax DHTML window. I want to redirect the page on different location when some one close开发者_开发百科d the window by clicking on cross image of window.

I have used following code to open window.

ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", popupURL, "Error Message", "width=450px,height=200px,resize=1,scrolling=1,center=1")


There are two events that can help you here, onbeforeunload and onunload. The onunload event may allow you to achieve what you need to, if it is fired by the browser.


Technically, the event you want to bind your callback to is called onUnload. Downside is that people got so damn annoying with triggering javascript pop-ups when leaving a website or closing a window, most the time it is considered 'user abuse' and blocked by most browsers (much like the javascript ability to overwrite the status bar/etc.

<opinion> Welcome to the web, its a stateless medium. See my comment below.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜