Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the browser's address bar without refreshing the page?

People also ask

How do I change my browser URL without reloading?

history. pushState({page: "another"}, "another page", "example. html"); This will change the URL, but not reload the page.

Which method is used to change the address in address bar of the browser?

HTML5 History API allows browsers to change the URL in browser address bar without reloading or refreshing the page using pushState function. The pushState method works similar to window.

How do I change my browser address?

Open Google Chrome, then select the three, vertical dots next to the profile icon. Select Settings, then under Appearance, turn the toggle for Show home button to on. Choose the option you'd like to use: New Tab page or Enter custom web address.

How do I keep the same URL in the address bar?

Buy a domain name and then make a redirection (maybe you can ask for this to your hosting provider). Fastest way: use an iframe.


With HTML5 you can modify the url without reloading:

If you want to make a new post in the browser's history (i.e. back button will work)

window.history.pushState('Object', 'Title', '/new-url');

If you just want to change the url without being able to go back

window.history.replaceState('Object', 'Title', '/another-new-url');

The object can be used for ajax navigation:

window.history.pushState({ id: 35 }, 'Viewing item #35', '/item/35');

window.onpopstate = function (e) {
  var id = e.state.id;
  load_item(id);
};

Read more here: http://www.w3.org/TR/html5-author/history.html

A fallback sollution: https://github.com/browserstate/history.js


To add to what the guys have already said edit the window.location.hash property to match the URL you want in your onclick function.

window.location.hash = 'category-name'; // address bar would become http://example.com/#category-name

I believe directly manipulating the address bar to a completely different url without moving to that url isn't allowed for security reasons, if you are happy with it being

www.mysite.com/products/#{selectedCat}

i.e. an anchor style link within the same page then look into the various history/"back button" scripts that are now present in most javascript libraries.

The mention of update panel leads me to guess you are using asp.net, in that case the asp.net ajax history control is a good place to start


I don't think this is possible (at least changing to a totally different address), as it would be an unintuitive misuse of the address bar, and could promote phishing attacks.