Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/jerrykingxyz/url-change-event
- Owner: jerrykingxyz
- License: mit
- Created: 2019-08-17T11:38:05.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-10T07:01:55.000Z (about 1 year ago)
- Last Synced: 2024-10-12T23:47:15.738Z (about 1 month ago)
- Topics: history-block, url-control, wrapper-event
- Language: JavaScript
- Homepage:
- Size: 210 KB
- Stars: 13
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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