[HTML] window.history 스펙
ITWeb/개발일반 2016. 7. 13. 17:50window.history 스펙이라기 보다 그냥 history interface 내용을 가져온 것입니다.
원문)
https://html.spec.whatwg.org/multipage/browsers.html#the-history-interface
내용)
enum ScrollRestoration { "auto", "manual" }; interface History { readonly attribute unsigned long length; attribute ScrollRestoration scrollRestoration; readonly attribute any state; void go(optional long delta = 0); void back(); void forward(); void pushState(any data, DOMString title, optional USVString? url = null); void replaceState(any data, DOMString title, optional USVString? url = null); };
본 내용을 찾아본 이유는 location.href 값을 변경하고 싶었고 변경 시 reloading 되지 않도록 하기 위해서 입니다.
pushState, replaceState 를 이용하면 원하는 기능을 구현 할 수 있습니다.
설명)
history
. length
Returns the number of entries in the joint session history.
history
. scrollRestoration
[ = value ]Returns the scroll restoration mode of the current entry in the session history.
Can be set, to change the scroll restoration mode of the current entry in the session history.
history
. state
Returns the current state object.
history
. go
( [ delta ] )Goes back or forward the specified number of steps in the joint session history.
A zero delta will reload the current page.
If the delta is out of range, does nothing.
history
. back
()Goes back one step in the joint session history.
If there is no previous page, does nothing.
history
. forward
()Goes forward one step in the joint session history.
If there is no next page, does nothing.
history
. pushState
(data, title [, url ] )Pushes the given data onto the session history, with the given title, and, if provided and not null, the given URL.
history
. replaceState
(data, title [, url ] )Updates the current entry in the session history to have the given data, title, and, if provided and not null, URL.