1 Reply Latest reply: Oct 31, 2012 4:45 AM by gimbal2 RSS

    Browser Back Button

    user8611954
      we have application and want to implement browser back.

      When user is in page2.jsp and click Browser Back button then :

      we want to fire a javascript, that will alert user showing popup with warning (You would loose data if you go Back ! ) and then Ok button and Cancel button on it.

      If user click Ok then he would go to previous page ( page1.jsp). If user clicks Cancel button then ofcourse user will stay on same page (page2.jsp).

      Can anyone share implenmented such script that works on all browsers ?

      thanks,
      sd
        • 1. Re: Browser Back Button
          gimbal2
          user8611954 wrote:
          we want to fire a javascript, that will alert user showing popup with warning (You would loose data if you go Back ! ) and then Ok button and Cancel button on it.
          Really? In this day and age where everyone installs popup blockers (or browsers just come with them built in) you still want to commit the cardinal sin of web app design (other than showing blinking text)?
          If user click Ok then he would go to previous page ( page1.jsp). If user clicks Cancel button then ofcourse user will stay on same page (page2.jsp).
          Can anyone share implenmented such script that works on all browsers ?
          Javascript provides an event for it.

          http://stackoverflow.com/questions/1704533/intercept-page-exit-event

          Twas an easy Google, took me about 20 seconds. Also note that Javascript is in no way related to Java; off-topic questions are usually locked.

          EDIT:

          oh, and you also cross-posted this I see. Nice.

          Browser Back - Warning