@saekitominaga/htmlformelement-before-unload-confirm
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Show confirmation dialog message when page is tries to close while filling out a form.

npm version Build Status Coverage Status

If the page is tries to close with the contents of the form control changed, a confirm dialog is displayed to prevent the changes from being discarded.

Demo

Examples

<script type="module">
import FormBeforeUnloadConfirm from './dist/FormBeforeUnloadConfirm.js';

for (const formElement of document.querySelectorAll('.js-form-beforeunload-confirm')) {
  const formBeforeUnloadConfirm = new FormBeforeUnloadConfirm(formElement);
  formBeforeUnloadConfirm.init();
}
</script>

<form class="js-form-beforeunload-confirm">
  <p><input /></p>
  <p><button>Submit</button></p>
</form>

Constructor

new FormBeforeUnloadConfirm(
  thisElement: HTMLFormElement
)

Parameters

thisElement [required]
Target element

Keywords

none

Install

npm i @saekitominaga/htmlformelement-before-unload-confirm

DownloadsWeekly Downloads

0

Version

1.2.4

License

MIT

Unpacked Size

39.1 kB

Total Files

8

Last publish

Collaborators

  • saekitominaga