Results 1 to 2 of 2

Thread: Catch Browser Button events.

  1. #1
    Join Date
    Jun 2008

    Catch Browser Button events.

    Hi All,

    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()">

    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

  2. #2
    Join Date
    Aug 2007
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center