I am displaying a warning dialog box whenever user tries to navigate from current page without saving data on current page. Its working fine now I want to call a function (Spring controller, its kind of java function which handled URL mappings ) when user clicks on Ok (in warning dialog box) and then he should get redirectd to desired page.
Let me try to make it simple (Its confusing for me also):
- User is on registration page, he/she made some changes and didn’t save it.
- Now user clicked on any other link for example he clicked on
About Uslink. - Now I want to execute my spring controller.
- After execution of controller user should get navigated to
About Uspage.
For this I need to save value of clicked hyperlink and pass it to my spring controller.
So how can I store URL of clicked link (URL ofAbout Uspage in above example) ?
PS: I will really appreciate if anybody can edit my question to make it easier to understand.
if you use jQuery, you can attach an event handler to onclick to all links in the page and once clicked the handler should save the href attribute to some variable. then create a onbeforeunload event listener on your window, where you can use the value however you want, call your controller or save the value in a cookie or something.