반응형
[javascript] 새로고침 없이 파라미터 제거/수정
Remove URL parameters without refreshing page
window.history.pushState({}, document.title, "/" + myNewURL );
https://stackoverflow.com/questions/22753052/remove-url-parameters-without-refreshing-page
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.replaceState() https://developer.mozilla.org/ko/docs/Web/API/History/replaceState
반응형
'프로그래밍 > Script' 카테고리의 다른 글
스크립트 정규식을 화면으로 보여주는 사이트 - regulex (0) | 2023.08.22 |
---|---|
[javascript] history.pushState ( 화면 전환 ) (0) | 2023.08.08 |
[javascript] 파라미터 제거하기. remove url parameters with javascript or jquery (0) | 2023.08.03 |
[JAVASCRIPT] 25 Killer JavaScript One-Liners That’ll Make You Look Like a Pro (0) | 2023.08.03 |
[jQuery] 숫자에 콤마 제거, replace comma (0) | 2023.07.28 |