I use for development ASP.NET MVC5. There was a need on the page that displays the results of the query, the data for which is taken from the HTML form, to prevent the browser’s standard behavior when pressing the F5 key, so that instead of displaying the request for resubmitting the form, the client is redirected to another resource by a strictly specified URI. Not very strong in javascript.
- No way - with a post request - you can try the get method. Can you show your markup and the code where the form is sent and how to determine where to redirect? - Grundy
|
1 answer
I found this trivial way out of the situation: when adding the following javascript code to the page, a redirect is made to the specified URL, instead of updating, when you click on F5:
function disableF5(e) { if ((e.which || e.keyCode) == 116) { e.preventDefault(); window.location.href = window.location.href.toString(); } }; $(document).ready(function () { $(document).on("keydown", disableF5); }); |