Hello Community,
I have one scenario to take care.
When somebody navigates out of application via entering some other URL or hitting bookmarks, I want to show a Outsystems popup with yes and no
If yes, i will allow navigation and if no, then stay at same page.
e.g:-
I am at some URL1, I type URL2 in address bar and hit enter, i expect that popup.
Hi,You can use the window.onbeforeunload function under the layout/page.. . & invoke your respective action.
Ref Sample : https://code-maven.com/prevent-leaving-the-page-using-plain-javascript
Good Luck
Hello Asif,
Thanks for the solution, But this solution brings the browser default popup of leaving the site.
My req is calling outsystems popup.
Can you please help weather i can achieve that?
Thanks,
Krunal
- You can remove the return from the snippet- Keep the Popup in the layout & let's say a hidden element[ can be button]; onclick of the element should call the popup... similar to what we do normally with Outsystems- Now in the JS Snippet function; you just need to call the onClick of that element
Hello Assif,
I called my client action in the javascript
But without return it does not call the action and navigates outor i can say that it does not stop navigation
Hi,Yes :(- I gave a try with the same & yes... when we use return it works fine i.e it holds the navigation
- And if we remove return & call button-click or a click with return itself.. which is an OS popup in our case.. the popup render but the navigation is triggered
- Also going with the default Alert ... has a limitation; you cannot use the custom message. Most of the browsers will ignore the actual message and just show their own.
Yes assif
We are facing that challenge
We want to build a pleasant UI experience for this behavior but not able to.