Skip to content

Prevent page unloading from the user's action

License

Notifications You must be signed in to change notification settings

preco21/prevent-unload

Repository files navigation

prevent-unload

Code Style Prev NPM Version Build Status Dependency Status

Prevent page unloading from the user's action

Install

$ npm install prevent-unload

Usage

import preventUnload, {cancel} from 'prevent-unload';

const handler = preventUnload();
cancel(handler);

API

preventUnload([message])

  • message String (optional) - Message to display on confirm popup. Default is platform specified.

Apply page unloading prevention. If user attempt to close current web page after calling the method, then browser blocks page unloading and shows up popup with specified message.

This method returns reference of handler, which can be used for cancel the behavior.

preventUnload.cancel(handler)

  • handler Function - Handler reference to cancel event.

Cancel page unloading prevention.

License

MIT

About

Prevent page unloading from the user's action

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published