jasalguero
jasalguero

Reputation: 4181

Google Translate writing on the browser url bar

I just noticed that now when using Google Translate, the site is updating also the browser url bar in real time when you write something like:

http://translate.google.com/#en|fr|hello

But the page doesn't reload as I am used to see when using document.location.href=newurl

So, my questions are:

1 - How do they achieve this effect?

2 - Is it considered a good practice? I can see the benefits, reloading the site now doesn't make it lose the parameters, but it also makes the browser history quite dirty because is also keeping all the intermediate steps

Thanks in advance

Upvotes: 1

Views: 393

Answers (2)

julesbou
julesbou

Reputation: 5780

You can use location.hash = 'en|fr|hello';

EDIT: see Modify the URL without reloading the page

Upvotes: 1

Jon Grant
Jon Grant

Reputation: 11520

Anything after the # doesn't cause the page to reload.

Upvotes: 2

Related Questions