I want to avoid page load but the URL should change and should be same in all browser. I am trying to use Ajax post with URL change. I have searched and found it is possible using # or .pushstates().
Link : Change the URL in the browser without loading the new page using JavaScript
I tried by using .pushstates() but it doesn't work in IE < 10. I don't want to use # in the URL. Is there any way to achieve this in IE?
Method 2: Adding a new state with pushState() Method: The pushState() method is used to add a new history entry with the properties passed as parameters. This will change the current URL to the new state given without reloading the page.
Shallow routing allows you to change the URL without running data fetching methods again, that includes getServerSideProps , getStaticProps , and getInitialProps . You'll receive the updated pathname and the query via the router object (added by useRouter or withRouter ), without losing state.
In fact, JavaScript provides the location object, a part of the window object, which allows you to perform different URL-related operations.
reload() method reloads the current URL, like the Refresh button. location. reload(); It has an optional parameter forceReload , which defaults to false when forceReload is true .
I'm afraid that the answer is just a plain no, there is no way to achieve this in IE.
You will have to accept using the hash if you want to identify different resources your application with the URL without reloading the page.
Note: the semantic of the hash is precisely to identify different resources within the same page, so if you don't reload the page, using the hash might actually be a good thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With