开发者

calling a javascript function when user clicks 'X' to close a form

I already have a 'Close' button that calls some javascript function. However, if the user just clicks the 'X' to close, the function is never called.

Any wa开发者_如何转开发y to call a function when 'X' is clicked, or hide the 'X'?

Thanks.


Use the "onbeforeunload" javascript event to catch when the user attempts to close the browser or navigate away.

<html> 
<head>
<title>< /title>
</head>

<body onbeforeunload="alert('Closing');">
</body> 
</html> 


You need to look into the (non-standard) onbeforeunload event

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜