[javascript] 새로고침 없이 파라미터 제거/수정. Remove URL parameters without refreshing page
[javascript] 새로고침 없이 파라미터 제거/수정
Remove URL parameters without refreshing page
window.history.pushState({}, document.title, "/" + myNewURL );
https://stackoverflow.com/questions/22753052/remove-url-parameters-without-refreshing-page
Remove URL parameters without refreshing page
I am trying to remove everything after the "?" in the browser url on document ready. Here is what I am trying: jQuery(document).ready(function($) { var url = window.location.href; url = url...
stackoverflow.com
1- The pushState() method if you want to add a new modified URL to history entries.
2- The replaceState() method if you want to update/replace current history entry.
.replaceState() operates exactly like .pushState() except that .replaceState()
For one liner fans, try this out in your console/firebug and this page URL will change:
window.history.pushState("object or string", "Title", "/"+window.location.href.substring(window.location.href.lastIndexOf('/') + 1).split("?")[0]);
This page URL will change from:
http://stackoverflow.com/questions/22753052/remove-url-parameters-without-refreshing-page/22753103#22753103
To
http://stackoverflow.com/22753103#22753103
History: pushState() method
https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
History: pushState() method - Web APIs | MDN
In an HTML document, the history.pushState() method adds an entry to the browser's session history stack.
developer.mozilla.org
History.replaceState() https://developer.mozilla.org/ko/docs/Web/API/History/replaceState
History.replaceState() - Web API | MDN
History.replaceState() 메서드는 현재 history를 수정해 메소드의 매개 변수에 전달 된 stateObj, title, URL로 대체합니다. 이 방법은 특히 일부 유저의 동작에 대한 응답으로 history 객체의 상태나 현재 history
developer.mozilla.org