Fire Dragon Posted February 16, 2006 Share Posted February 16, 2006 Well,I saw this kind code somewhere,but I can't remember where,so I decided ask.I want that,when tries close window,function happens.Like,alert "Bye,bye!" orprompt,"are you sure?"Something like this.I have seen this in some sites in web.Thanks for help! Link to comment Share on other sites More sharing options...
scott100 Posted February 16, 2006 Share Posted February 16, 2006 I would only use this on a pop up window, not your main window. but you can if you want <head><script>function check(){var answer = confirm ("Do you want to close this window?")if (answer)window.close();else alert ("Thanks for staying")}</script></head><input type="button" value="close window" onclick="check()" /> Link to comment Share on other sites More sharing options...
vijay1440 Posted February 17, 2006 Share Posted February 17, 2006 Well,I saw this kind code somewhere,but I can't remember where,so I decided ask.I want that,when tries close window,function happens.Like,alert "Bye,bye!" orprompt,"are you sure?"Something like this.I have seen this in some sites in web.Thanks for help!<{POST_SNAPBACK}> hi! i think it works<body onUnload="confirmOnce()"><script language=javascript>function confirmOnce(){ if (window.event.clientX<0 && window.event.clientY<0) { alert("Bye Bye"); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now