Answer the question
In order to leave comments, you need to log in
Change URL without reloading the page?
Hello.
I found that while scrolling through photos in VKontakte with arrows, the URL in the address bar changes. This does not reload the page. Firebug shows that only photos are pulled and that's it. Only works in latest Chrome and Firefox. In other browsers, the link is obtained with a hash (#).
location.hash is clear that you can change without reloading the page, but how is the complete change of the URL implemented in this case? After all, location.href does not allow you to change the URL without reloading.
Answer the question
In order to leave comments, you need to log in
var setLoc = function(loc) {
//curLoc = fixEncode(loc.replace(/#(\/|!)?/, ''));
curLoc = fixEncode(loc);
var l = (location.toString().match(/#(.*)/) || {})[1] || '';
if (!l && vk.al > 1) {
l = (location.pathname || '') + (location.search || '');
}
l = fixEncode(l);
if (l.replace(/^(\/|!)/, '') != curLoc) {
if (vk.al == 3) {
try {
history.pushState({}, '', '/' + curLoc);
return;
} catch(e) {}
}
window.chHashFlag = true;
location.hash = '#' + vk.navPrefix + curLoc;
if (withFrame && getLoc() != curLoc) {
setFrameContent(curLoc);
}
}
}
Pulled out by fireBug from VK. so you are wrong)
Yes, it works in Chrome too.
Here, I googled it: www.w3.org/TR/html5/author/history.html#session-history-entry
why not, you can:
window.location.href=/qa/6436/#photo"
if there is # in the url and the url itself matches, there will be no reload
Perhaps this option is suitable
diveintohtml5.info/examples/history/gallery/casey.html
here for more details htmlbook.ru/html5/history
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question