We have a requirement to show a survey popup in the web pages of our website. The requirement is to show the popup when the user leaves the website. The code to show the popup is written as a javascript function like
function callSurvey(){
if (showSurveyPopup) {
//Code to show survey window.
}
}
This is called from the unload call back method of the web page like
<body onunload="callSurvey()">
.....
</body>
All the link clicking events in the web page document which causes a page UNLOAD is caught before unload event and we will reset the showSurveyPopup variable to false. Also the F5 and Ctrl +R key also caught and the variable is reset to avoid showing the pop up in a wrong scenario.
But now we have a problem like the survey popup will be shown whenever the BACK,FORWARD or the REFRESH button of the web browser is clicked. Is there any way I can know whether the USER has clicked BACK , FORWARD or REFRESH button of the browser so that I can reset the showSurveyPopup to false, before the ONUNLOAD method is triggered .
If that is not possible is there any way to disable these buttons. Please provide some code snippets if available.
All comments and answers welcome.
Thanks in advance
Jacob
You cannot disable them for sure, and as far as I know, you don't know what button, if any, has been pressed.
It should only show once, right? Then you could use a cookie to store the variable.
Great wit and madness are near allied, and fine a line their bounds divide.
Bookmarks