공통점 ⚽️
- 윈도우에 기존 리소스(페이지)를 다른 URL로 바꿔서 보여줌.
- 문법
assign(url)
replace(url)
url에는 이동할 페이지 URL을 적으면 됨.
차이점 🚘
replace | assign |
현재 페이지가 세션 기록에 저장되지 않음 | 현재 페이지가 세션 기록에 저장됨 |
사용자가 뒤로 가기 버튼을 클릭해도, 해당 페이지로 이동할 수 없음 | 사용자가 뒤로 가기 버튼으로 해당 페이지로 이동 가능함 |
히스토리 ?
- 브라우저의 세션 기록을 조작할 수 있게 해줌. (세션 기록 바로 뒤로 이동, 세션 기록 바로 앞으로 이동, 세션 기록 스택에 특정 데이터, 지정 제목, url를 넣거나 교체하기 등)
https://developer.mozilla.org/ko/docs/Web/API/History
History - Web API | MDN
History 인터페이스는 브라우저의 세션 기록, 즉 현재 페이지를 불러온 탭 또는 프레임의 방문 기록을 조작할 수 있는 방법을 제공합니다.
developer.mozilla.org
참고 자료 🔖
https://developer.mozilla.org/en-US/docs/Web/API/Location/assign
location.assign() - Web APIs | MDN
The Location.assign() method causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.assign() by pressing the "back" button.
developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
location.replace() - Web APIs | MDN
The replace() method of the Location interface replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won
developer.mozilla.org
'프론트엔드💛' 카테고리의 다른 글
좌충우돌 처음 해보는 메일 HTML 코딩 💌 (0) | 2022.09.20 |
---|---|
[Vue3] 입력 받은 이미지 preview(썸네일) 보여주기 (0) | 2022.09.13 |
[Webpack 미니 시리즈] 4부. Webpack과 Vite(작성 예정) (0) | 2022.09.10 |
자바스크립트 문자열 길이 맞추기-시간 0:0 -> 00:00 으로 맞추고 싶다면 (0) | 2022.09.06 |
Cross storage가 뭔가요? 왜 필요한가요? (0) | 2022.08.29 |