@handcraftech/plugin-route-url-change-event
v0.2.0
Published
A plugin that listens and controls URL changes
Downloads
4
Readme
URL Changel Event
a wrapper event that listen & control URL changes
Installation
you can install with npm install @handcraftech/plugin-route-url-change-event
/* in ES 5 */
require('@handcraftech/plugin-route-url-change-event')
/* in ES 6 */
import '@handcraftech/plugin-route-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('urlchange', 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
