을 사용자가 현대적인 브라우저 (IE 아니라 거의 아무것도)를 사용하는 경우, 당신은 새로운 HTML5 history methods를 사용할 수 있습니다. 구체적으로는 history.replaceState
입니다.
replaceState()
페이지를 다시로드하지 않고 URL을 변경합니다.
$.post('/some/url/', {some: data}, function(d){
// Do whatever with the returned data...
// Change page URL
history.replaceState({}, '', '/some/url/');
});
아니면 데이터를로드하기 전에 URL을 변경할 수 있습니다 : 당신은 다음과 같이 사용할 수 있습니다
// Change page URL
history.replaceState({}, '', '/some/url/');
// load page data
$.post('/some/url/', {some: data}, function(d){
// Do whatever with the returned data...
});
을 replaceState
의 예를 들어, 여기 : https://github.com/features/projects을하고, 4 개 탭을 클릭합니다. URL 변경 사항을 살펴보세요. 그러나 기록에 추가 된 내용은 없습니다 :-)
, 당신이 사용할 수있는 HTML5의 ['History.pushState'] (http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate) . –
하지만 현재 URL이 아니라 기록을 수정합니다. – Armin
@Armin : 현재 URL을 변경하지 않고 [History.replaceState'] (https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#The_replaceState() .C2A0method)가 있습니다. . –