0

Hello i am using query string to pass value from one page to another but while refresh it show same message so can we clear link and change link on browser refresh button ?

if have this link http://localhost:56980/Admin/Welcome.aspx?mess=1

but i want this link after refresh page

http://localhost:56980/Admin/Welcome.aspx

  • You should chek in javascript if your page is reloaded https://stackoverflow.com/questions/5004978/check-if-page-gets-reloaded-or-refreshed-in-javascript and redirect your current page to a parameter-stripped one https://www.w3schools.com/js/js_window_location.asp – B. Lec Feb 03 '20 at 07:49
  • not getting your point can you please send some example ? – riha bohra Feb 03 '20 at 08:26

1 Answers1

0

Here is a client-side solution

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
     <body onload="return CheckRefresh()">
        <h1>test</h1>
        <script>
            function CheckRefresh() {
                if (performance.navigation.type == 1) {
                    window.location.href = removeURLParameters(window.location.href);
                }
            }
            function removeURLParameters(url) {
                    var urlparts = url.split('?');   
                    if (urlparts.length >= 2) {
                        return urlparts[0];
                    }
                    else {
                        return url;
                    }
            }
        </script>
    </body>
</html>
B. Lec
  • 312
  • 2
  • 13
  • actually i am using master page so should i call this function on my page load ? – riha bohra Feb 03 '20 at 09:38
  • If you want all the slave pages to have this behaviour, yes. Else you let the – B. Lec Feb 03 '20 at 11:57