AnthonyPanchenko / url-change-event

a wrapper event that listen & control URL changes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

url-change-event

a wrapper event that listen & control URL changes 中文

Installation

you can install with npm install url-change-event

    /* in ES 5 */
    require('url-change-event')
    /* in ES 6 */
    import 'url-change-event'

or

    <script src="url-change-event.js"></script>

Due to override some history method, you should import this lib before your code.

Usage

window.addEventListener('urlchangeevent', function(e) {
    // your code here
})

UrlChangeEvent instance

Properties

  • oldURL {URL} - the url before change.
  • newURL {URL | null} - the url after change. WARNING: when event.action is beforeunload, this value is null.
  • action {[pushState|replaceState|popstate|beforeunload]} - the action that causes the url to change.

Method

  • preventDefault - prevent url change

License

MIT licensed

About

a wrapper event that listen & control URL changes

License:MIT License


Languages

Language:JavaScript 100.0%