Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jerrykingxyz/url-change-event

a wrapper event that listen & control URL changes
https://github.com/jerrykingxyz/url-change-event

history-block url-control wrapper-event

Last synced: 18 days ago
JSON representation

a wrapper event that listen & control URL changes

Awesome Lists containing this project

README

        

# url-change-event
a wrapper event that listen & control URL changes
[中文](README_CN.md)

## Installation
you can install with ```npm install url-change-event```
```javascript
/* in ES 5 */
require('url-change-event')
/* in ES 6 */
import 'url-change-event'
```
or
```html

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

## Usage
```javascript
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