1228
Views
3
Comments
preventing URL reload
Question

Hi all,

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


2021-04-09 11-42-43
assif_tiger
 
MVP

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


2020-03-24 00-01-07
Nuno Gonçalo Pereira

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


2022-02-07 08-52-30
Pranav Pandey

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. :)

Sample.png
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.