티스토리 뷰

onhashchange

onhashchange.js 를 방금 릴리즈 했습니다.
https://github.com/powerumc/onhashchange

onhashchange 기능이 제공되는지 여부를 감지하고, 이를 지원하지 않는 오래된 브라우저인 경우 Polyfill 을 지원합니다.

아래의 호환 브라우저 미만인 경우 onhashchange Polyfill 이 동작하게 됩니다.

Implemented event fields.

The dispatched hashchange event has the following fields:

FieldTypeDescription
newURLDOMStringThe new URL to which the window is navigating.
oldURLDOMStringThe previous URL from which the window was navigated.

Browser compatibility

Desktop Mobile
Feature     Chrome          Firefox (Gecko)     Internet Explorer       Opera       Safari
Basic       support 5.0     3.6 (1.9.2)         8.0                     10.6        5.0

Ref. https://developer.mozilla.org/ko/docs/Web/API/WindowEventHandlers/onhashchange

Example

<html>
    <head>
        <script type="text/javascript" src="onhashchange.js"></script>
        <script>
            window.onhashchange = function(e) {
                alert("onhashchange");
            }
        </script>
    </head>

    <body>
        <p><a href="#a">#a</a></p>
        <p><a href="#b">#b</a></p>
        <p><a href="#c">#c</a></p>
    </body>
</html>


댓글
댓글쓰기 폼
공지사항
Total
2,841,738
Today
3
Yesterday
47
«   2023/06   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
글 보관함