Skip to content
/ Jailor Public

Allows web applications to register conditions under which an user will be asked to confirm exiting the page.

Notifications You must be signed in to change notification settings

MESHMD/Jailor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jailor

Allows web applications to register conditions under which an user will be asked to confirm exiting the page.

It is a simple wrapper over onbeforeunload (demo) that allows to add multiple conditions easily.

Example

var car = {
	wheelsCount: 2
}

instructionsDiv.textContent = 'Fix the car!';

Jailor.lock(function() {
	if (car.wheelsCount != 4) {
		return 'The car is expected to have 4 wheels, not ' + car.wheelsCount + '!';	// return an error-description string to ask confirmation from the user
	}	// return anything else than a string (or nothing) to allow the user to leave the page without any question
});

Notes

Jailor respects any previous onbeforeunload handler already in place, and will add it as a condition.

About

Allows web applications to register conditions under which an user will be asked to confirm exiting the page.

Resources

Stars

Watchers

Forks

Packages

No packages published