url-change-event
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

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

/url-change-event/

    Package Sidebar

    Install

    npm i url-change-event

    Weekly Downloads

    1,531

    Version

    0.1.7

    License

    MIT

    Unpacked Size

    6.29 kB

    Total Files

    5

    Last publish

    Collaborators

    • jerrykingxyz