a wrapper event that listen & control URL changes 中文
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.
window.addEventListener('urlchangeevent', function(e) {
// your code here
})
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
MIT licensed