I have to popup a popup window in my application when the user closes the browser or

go to different website. I have wrote the following Javascript code in my web page in <body "onunload"> Event

But the problem with the below code is that when the user clicks on back button or forward button also

the popup window is showing up. Is there any better way I can capture back button clicks.

And one more thing this code is not working in Fairfox browser. Can I get some help for

handling this issue in Fairfox browser.

Here is my code.


body onunload = "Popup()" >

<script type="text/javascript">

function SurveyPopup()


if (event.clientY <0)


if (window.showModalDialog) //modal window for Internet Explorer


surveywindow=window.showModalDialog('survey_Popup.htm','Surveywindow','center:yes;dialogWi dth:300px;dialogHeight:200px');


else //modeless window for other browsers


Surveywindow=window.open("survey_Popup.htm","Surveywindow","location=1,width=300,height=20 0,menubar=0,resizable=0,modal=yes");





Any help will be highly appreciated