Hi all,

I need to prevent url reload  onClick of browser back button. how can i achieve this?


Ronan T wrote:

Hi all,

I need to prevent url reload  onClick of browser back button. how can i achieve this?


Hi,

Ref : https://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript

Thanks


Hi!

You have to detect browser back button event and pass as an input of the page you want do prevent URL reload that indicates you if you came from a back button click.

you have to use a Run JavaScript Function to implement 

this code:

$(window).on('popstate', function(event) {
 alert("pop");
});

Instead of alert, you have to return "True" or "false", like:

$(window).on('popstate', function(event) {
 return true;
});

and then send the user to the page that you want to prevent URL Reload, passing the boolean value returned by this function.


OR 


You can use the value returned by this function through this app that is in the Forge:

https://www.outsystems.com/forge/component-overview/990/javascript-demo-how-to

1- Put an input variable hidden 

2-Put your Javascript Code on screen, using the extended properties to save the value returned by your function, using the "onkeypress" event such as this example:


I hope this will help you!

Best Regards,

Nuno Pereira


Hi Ronan T,

I have too witness this scenario while incorporating excel down load functionality . Download function works only when the button or link type was of type submit and while doing so the page gets reloaded. In order to prevent this I used 'IsLoadingScreen()' function to check if the screen load is Postback or not . (User this function in preparation function).

Please find the screen shot in the attachments.

Hope this can help you. :)