If the user has changed data but has not yet saved it, but then wants to leave the page or even close the browser, he should be informed of the unsaved state. It would be best if I could prevent leaving the page with unsaved data. Is that possible?
You can’t do that imho. So the user can handle the browser tools at any time and e.g., if not levered over a global property, press the back button of the browser .. or switch off the computer unhindered.