-2

I am working on one payment getway project my boss give me a one task disable browser closing while transaction process I am try last two days but i can't perfectly done so any one please help me ....(JSP/Servlet) Thanks in Advance

  • This link can be useful http://stackoverflow.com/questions/1565304/jquery-prevent-window-closing – brk Mar 07 '16 at 06:25
  • You can ask the user if they really want to leave the current page if the user is trying to navigate to another page. But, you cannot prevent the closing of the browser. You cannot prevent the user navigating away from the page if the user wants to. The browser/user control things, NOT Javascript in the page and it has to be that way to prevent web pages from being evil. You should advise the user to leave the window open until the transaction completes so they can see the result, but you cannot force it. – jfriend00 Mar 07 '16 at 06:27
  • same thing i want to do on servlet page but servlet has no view it just doing Transaction Action After Submitting the jsp of account details – Vaibhav Pandya Mar 07 '16 at 07:20

1 Answers1

0

Dear,

  1. First of keep a thing in mind that you can't prevent user to close any window or tab.
  2. Only what you can do is to remind him by creating alert / confirm box if he tries to close any window or tab.

Now, coming to the point you just have to add event name onbeforeunload using javascript. That could be done like this :

window.onbeforeunload = function() {
    return 'You have unsaved changes!';
}

Thanks & Cheers :)

Amulya Kashyap
  • 2,333
  • 17
  • 25
  • same thing i want to do on servlet page but servlet has no view it just doing Transaction Action After Submitting the jsp of account details... – Vaibhav Pandya Mar 07 '16 at 07:20