JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.js"></script>
<script src="https://gist.github.com/raw/4657291/f68ad946593bfe95b7593d826b95c2b78b07b8dc/beforeUnloadText.js"></script>
<body data-bind="beforeUnloadText: beforeUnloadPrompt">
<input type="text" value="Hello World!" />
<button data-bind="click:Save">Save</button>
<br />
<a href="http://jsfiddle.net/tlarson/WY9QP/">some link</a>
</body>
JavaScript
var ViewModel = function() {
var self = this;
self.Save = function() {
// Setting the prompt to null will cause the
// prompt to not appear when the user is
// navigation away from the page
self.beforeUnloadPrompt(null);
}
self.beforeUnloadPrompt = ko.observable("You forgot to save your work");
};
ko.applyBindings(new ViewModel());